candidates_get_by_levenshtein {votesmart}R Documentation

Get candidate data by Levenshtein distance from last name

Description

From the API docs, http://api.votesmart.org/docs/Candidates.html, "This method grabs a list of candidates according to a fuzzy lastname match."

Usage

candidates_get_by_levenshtein(
  last_names,
  election_years = lubridate::year(lubridate::today()),
  stage_ids = "",
  all = TRUE,
  verbose = TRUE
)

Arguments

last_names

Vector of candidate last names

election_years

Vector of election years. Default is the current year.

stage_ids

The stage_id of the election ("P" for primary or "G" for general). See also election_get_election_by_year_state.

all

Boolean: should all possible combinations of the variables be searched for, or just the exact combination of them in the order they are supplied?

verbose

Should cases when no data is available be messaged?

Details

The actual Levenshtein distance of the result from the last_name provided is not available from the API.

Value

A dataframe of candidates and their attributes. If a given last_name + election_year + stage_id combination returns no data, that row will be filled with NAs.

Examples

## Not run: 
candidates_get_by_levenshtein(c("Bookr", "Klobucar"), 2020)

## End(Not run)

[Package votesmart version 0.1.2 Index]