electionsBR

R Functions to Download and Clean Brazilian Electoral Data

Offers a set of functions to easily download and clean
Brazilian electoral data from the Superior Electoral Court website.
Among others, the package retrieves data on local and
federal elections for all positions (city councilor, mayor, state deputy,
federal deputy, governor, and president) aggregated by
state, city, and electoral zones.

electionsBR

electionsBR offers a set of functions to easily pull and clean Brazilian electoral data from the Brazilian Superior Electoral Court (TSE) website. Among others, the package retrieves data on local and federal elections for all positions (city councilor, mayor, state deputy, federal deputy, governor, and president) aggregated by state, city, and electoral zones.

electionsBR is on CRAN and can be installed with:

install.packages("electionsBR")

electionsBR is also available on GitHub. You can install pre-release versions via:

if (!require("devtools")) install.packages("devtools")

devtools::install_github("silvadenisson/electionsBR")

How does it work?

To download data from a given election, only the year argument must be passed to the function call:

library(electionsBR)

df <- candidate_fed(year = 2002)

You may also export Brazilian electoral data to Stata and SPSS by setting the export optional argument to TRUE:

df <- candidate_fed(2002, export = TRUE)

As well as subset your results by state using the uf argument:

df <- vote_mun_zone_fed(2002, uf = "RS")

For more information on how the package works and for a complete list of functions, see the vignette.

Citation

To cite electionsBR in publications, please use:

citation("electionsBR")

Authors

News

electionsBR 0.3.0

We changed central aspects of the package, which affected all the functions in it (but without compromising backward compability). Beyond that, in this update we did our best to make the package more user friendly: we created a vignette, included more options to filter and customize functions' outputs, and added more specific functions (including one to easily export electoral data). With this new uptade, the package also gained a website. Overrall, this is what we did:

Updated the package to (1) load and clean data faster (with data.tables' fread() and rbindlist()), (2) to make the package more robust to human errors (new internal functions to test inputs), and (3) to return a simples object (a dplyr tbl).

Included two new functions to summarize presidential runnoff results by state (president_state_vote()) and by municipality (president_mun_vote()).

Included two new functions to summarize legislative election results by state (legislative_state_vote()) and by municipality (legislative_mun_vote()).

Included one new function to get data on the number of seats being disputed in each election (available_seats()).

Included an optional argument in most functions to export electoral data to Stata or SPSS.

Included an optional argument in most functions to filter results by state (UF).

Created one vignette.

Updated the README.

electionsBR 0.2.0

Added a NEWS.md file to track changes to the package.

Included year = 2016 option for local elections.

Updated candidate_local documentation.

Included an option to convert electoral data from Latin-1 encoding to ASCII.

Removed the exportation of some internal functions.

Added a new function, voter_affiliation, to collect dato on voters' affiliation.

Added a new function, voter_profile, to collect dato on voters' profile.