get_vote: get_vote

Description Usage Arguments Value Examples

View source: R/get_vote.R

Description

Function to get vote count data for a given date from the AP API's elections endpoint

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get_vote(
  key = Sys.getenv("apelex_api_key"),
  date = NULL,
  state = NULL,
  level = NULL,
  office_id = NULL,
  winner = NULL,
  race_type = NULL,
  party = NULL,
  test = FALSE,
  national = TRUE,
  uncontested = FALSE
)

Arguments

key

Supplied API key

date

Election date supplied in the format of Y-M-D

state

Optional parameter for state supplied as postal code, e.g. "IA"

level

Level of reporting units. Can take arguments for state, district, fipscode, or reporting unit

office_id

AP ID code for the office position. Optionally can be a list or vector of IDs

winner

If a winners has been declared. Can supply "X" if a races has a declared winer, R if there is a run-off, U if there is no declared winner, or A for all. Defaults to all.

race_type

Type of election. Optionally can be list or vector of types

party

political party

test

TRUE/FALSE. Whether to use test data (TRUE) or production data (FALSE). Defaults to FALSE.

uncontested

Value

Returns a tidy dataframe of election results

Examples

1
test_ia <- get_vote(key = Sys.getenv("apelex_api_key"), level = "fipscode", state = "IA", date = "2020-02-03")

willdebras/apelex documentation built on Oct. 10, 2020, 11:48 p.m.