MyNixOS website logo
Description

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 R-CMD-check AppVeyor Build Status downloads

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.

Installation

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 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:

library(electionsBR)
df <- elections_tse(year = 2002, type = "candidate")

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:

df <- elections_tse(year = 2022, type = "vote_mun_zone", br_archive = TRUE)

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):

df <- elections_tse(year = 2002, type = "candidate", export = TRUE)

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:

df <- elections_tse(year = 2000, type = "vote_mun_zone", uf = "RS")

For detailed information on the package's functionality and a complete list of functions, see the package vignette.

Available data

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"):

typeDescription
candidateDownloads data on the candidates. Each observation corresponds to a candidate.
vote_mun_zoneDownloads data on the verification, disaggregated by cities and electoral zones.
details_mun_zoneDownloads data on the details, disaggregated by town and electoral zone.
legendsDownloads data on the party denomination (coalitions or parties), disaggregated by cities.
party_mun_zoneDownloads data on the polls by parties, disaggregated by cities and electoral zones.
personal_financesDownloads data on personal financial disclosures. Each observation corresponds to a candidate's property.
seatsDownloads data on the number of seats under dispute in elections.
vote_sectionDownloads data on candidate electoral results in elections in Brazil by electoral section.
voter_profile_by_sectionDownloads data on the voters' profile by vote section.
voter_profileDownloads data on the voters' profile.
social_mediaDownloads data on the candidates' links to social media in federal elections.

CEPESP Data Integration

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:

typeposition
candidate, votePresident, Governor, Senator, Federal Deputy, State Deputy

Citation

If you have found electionsBR helpful for your work and would like to acknowledge it in a resulting publication, please consider citing it using:

citation("electionsBR")

Authors

Denisson Silva, Fernando Meireles, and Beatriz Costa.

Contributors

Willber Nascimento, Ian Araujo, Guilherme Duarte Jardim, Robert Myles McDonnel, Lucas Gelape.

Metadata

Version

0.4.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows