6 years in and over 40,000+ downloads! 🎉
electionsBR
provides a comprehensive set of functions for effortlessly retrieving and cleaning Brazilian electoral data from the Brazilian Superior Electoral Court (TSE) website. The package allows you to access several datasets on local and federal elections for various positions, including city councilors, mayors, state deputies, federal deputies, governors, and presidents, as well as data on voters’ profiles, candidates’ social media, and personal financial disclosures. The package also provides an alternative API to download data from the CEPESP Data project.
electionsBR
is on CRAN and can be installed with:
electionsBR
is also available on GitHub. You can install pre-release versions via:
if (!require("devtools")) install.packages("devtools")
devtools::install_github("silvadenisson/electionsBR")
To download data from a specific election, simply provide the year
and type
arguments in the function call. For instance, to retrieve data on candidates from the 2002 election, use the following code:
For some data types in presidential elections, TSE provides results in a single file. To download these data, use the br_archive
argument as follows:
Export Brazilian electoral data to Stata and SPSS formats by setting the export
optional argument to TRUE
(the data will be saved in your working directory):
To subset results by Brazilian states, use the uf
argument. For example, to get data on votes for municipal elections in Rio Grande do Sul (RS) in 2000:
For detailed information on the package’s functionality and a complete list of functions, see the package vignette.
The elections_tse
function allows you to download the following data (by setting the type
argument to the corresponding value in the table below, e.g., type = "candidate"
):
type |
Description |
---|---|
candidate |
Downloads data on the candidates. Each observation corresponds to a candidate. |
vote_mun_zone |
Downloads data on the verification, disaggregated by cities and electoral zones. |
details_mun_zone |
Downloads data on the details, disaggregated by town and electoral zone. |
legends |
Downloads data on the party denomination (coalitions or parties), disaggregated by cities. |
party_mun_zone |
Downloads data on the polls by parties, disaggregated by cities and electoral zones. |
personal_finances |
Downloads data on personal financial disclosures. Each observation corresponds to a candidate’s property. |
seats |
Downloads data on the number of seats under dispute in elections. |
vote_section |
Downloads data on candidate electoral results in elections in Brazil by electoral section. |
voter_profile_by_section |
Downloads data on the voters’ profile by vote section. |
voter_profile |
Downloads data on the voters’ profile. |
social_media |
Downloads data on the candidates’ links to social media in federal elections. |
The package also provides an alternative API for downloading data from the CEPESP Data project, including information on candidates, electoral results, and voters’ profiles. To download data on candidates in the 2018 presidential election, simply use the following code:
library(electionsBR)
df <- elections_cepesp(year = 2018, type = "candidate", position = "President")
Valid type
and position
arguments are:
type |
position |
---|---|
candidate , vote |
President , Governor , Senator , Federal Deputy , State Deputy |
If you have found electionsBR
helpful for your work and would like to acknowledge it in a resulting publication, please consider citing it using:
Denisson Silva, Fernando Meireles, and Beatriz Costa.
Willber Nascimento, Ian Araujo, Guilherme Duarte Jardim, Robert Myles McDonnel, Lucas Gelape.