| get_election_data | R Documentation |
Determines which county files are needed for the requested races, loads
them (downloading if necessary), and returns a combined data.frame with
only the relevant columns.
get_election_data(elections, source = NULL)
elections |
Character vector of race codes, e.g. |
source |
Character string or |
The counties to load are determined automatically from election_catalog.
For races spanning all counties (counties = "all"), every county in
county_catalog is loaded. For district-level races, only the relevant
counties are loaded.
To avoid specifying source in every call, set options(data_dir) once
at the start of your session or in your .Rprofile:
options(data_dir = "~/my_data/") # local files # or leave unset to use the online OSF repository
A data.frame with columns COUNTY, PRECINCT, and one column
per requested race. Rows from all relevant counties are combined via
rbind. Voters not eligible for a given race have NA in that column.
get_county_data(), ei_summary()
# Presidential and Senate races (all counties)
df <- get_election_data(c("PRE", "USS"))
# Including a district-level race (only counties with that race)
df <- get_election_data(c("PRE", "HOS3"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.