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

CRAN_Status_Badge Travis-CI Build Status AppVeyor Build Status

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

Denisson Silva, Fernando Meireles, and Beatriz Costa.

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.
  • Fixed an encoding issue when joinning collected data (avoid errors on Macs).
  • Added a new internal function, test_encoding, to validate encodings passed to the functions' calls.
  • Replaced cat with message in all functions. Users are now free to supress unwanted messages.
  • Added a CITATION file to /inst.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("electionsBR")

0.3.0 by Denisson Silva, a year ago


http://electionsbr.com/


Report a bug at https://github.com/silvadenisson/electionsBR/issues


Browse source code at https://github.com/cran/electionsBR


Authors: Denisson Silva [aut, cre], Fernando Meireles [aut], Beatriz Costa [ctb]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports magrittr, dplyr, data.table, haven, stats

Suggests knitr, rmarkdown


See at CRAN