Package 'electionsBR'

Title: R Functions to Download and Clean Brazilian Electoral Data
Description: Offers a set of functions to easily download and clean Brazilian electoral data from the Superior Electoral Court and 'CepespData' websites. Among other features, 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.
Authors: Denisson Silva [aut, cre], Fernando Meireles [aut], Beatriz Costa [ctb]
Maintainer: Denisson Silva <[email protected]>
License: GPL (>= 2)
Version: 0.5.0
Built: 2025-02-17 05:46:18 UTC
Source: https://github.com/silvadenisson/electionsbr

Help Index


R functions to download and clean Brazilian electoral Data

Description

electionsBR provides a set of tools to easily pull and clean several different Brazilian electoral data: election results; candidates' partisan affiliations, personal and professional backgrounds; Brazilian parties' electoral performances; composition of electoral coalitions; among many others.

Details

To learn more about electionsBR, check the package vignette and documentation.

Author(s)

Beatriz Costa (UFMG/Brazil) [ctb], Fernando Meireles (UFMG/Brazil) [author], Denisson Silva (UFMG/Brazil) [author]

See Also

Useful links:


Download data on the candidates' backgrounds in elections

Description

candidate() downloads and aggregates data on the candidates' background who ran in elections in Brazil. The function returns a data.frame where each observation corresponds to a candidate.

Usage

candidate(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year (integer). For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, 2022, 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'latin1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). temp

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

candidate returns a tbl, data.frame with the following variables:

Note

For the elections prior to 2002, some information can be incomplete. For the 2014 and 2018 elections, more variables are available.

Examples

## Not run: 
df <- candidate(2002)

## End(Not run)

Downloads data on the candidates - Addtional information

Description

candidate_add_infor() downloads and aggregates data on the candidates' background who ran in elections in Brazil. The function returns a data.frame where each observation corresponds to a candidate.

Usage

candidate_add_infor(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year (integer). For this function, only the years 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'latin1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). temp

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

candidate_add_infor returns a tbl, data.frame with the following variables:

Note

For the elections prior to 2024.

Examples

## Not run: 
df <- candidate_add_infor(2024)

## End(Not run)

Download data on the candidates' background in federal elections

Description

candidate_fed() downloads and aggregates the data on the candidates' background who competed in the federal elections in Brazil. The function returns a data.frame where each observation corresponds to a candidate.

Usage

candidate_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'latin1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). elections_rda

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

candidate_local() returns a data.frame

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variables are available.

Examples

## Not run: 
df <- candidate_fed(2000)

## End(Not run)

Download data on the candidates' background in local elections

Description

candidate_local() downloads and aggregates the data on the candidates' background who competed in the local elections in Brazil. The function returns a data.frame where each observation corresponds to a candidate.

Usage

candidate_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years of 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'latin1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). elections_rda

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

candidate_local() returns a data.frame with the following variables:

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- candidate_local(2000)

## End(Not run)

Download data on the verification of federal elections in Brazil

Description

details_mun_zone() downloads and aggregates data on the verification of federal elections in Brazil, disaggregated by town and electoral zone. The function returns a data.frame where each observation corresponds to a town/zone.

Usage

details_mun_zone(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, 202. 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). temp

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

details_mun_zone() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, 2022 and 2024 elections, more variables are available.

Examples

## Not run: 
df <- details_mun_zone(2002)

## End(Not run)

Download data on the verification of federal elections in Brazil

Description

details_mun_zone_fed() downloads and aggregates data on the verification of federal elections in Brazil, disaggregated by town and electoral zone. The function returns a data.frame where each observation corresponds to a town/zone.

Usage

details_mun_zone_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). elections_rda

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

details_mun_zone_fed() returns a data.frame with the following variables:

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variables are available.

Examples

## Not run: 
df <- details_mun_zone_fed(2002)

## End(Not run)

Download data on the verification of local elections in Brazil

Description

details_mun_zone_local() downloads and aggregates the data on the verification of local elections in Brazil, disaggregated by electoral zone. The function returns a data.frame where each observation corresponds to a town/zone.

Usage

details_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016 and 2020 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). elections_rda

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

details_mun_zone_local() returns a data.frame with the following variables:

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- details_mun_zone_local(2000)

## End(Not run)

Retrieve electoral data from the cepesp API.

Description

Retrieve electoral data from the cepesp API.

Usage

elections_cepesp(year, type, position, data_table = FALSE)

Arguments

year

The election year. Valid options are between 1998 to 2018 for positions such as President, Governor, Senator, Federal Deputy, State Deputy, and District Deputy. For Mayor or Councillor positions, valid options range from 2000 to 2016.

type

The type of data to retrieve. Valid options are "candidate" or "vote".

position

The position for which the data is requested. Valid options are President, Governor, Senator, Federal Deputy, State Deputy, District Deputy, Mayor, or Councillor.

data_table

If set to TRUE, the function will return the data as a data.table object. Default is FALSE.

Value

The function returns a tibble containing the requested elections data.

Note

The function is a wrapper for the cepesp API. To learn more about the API, please visit cepespdata.io.

Examples

## Not run: 
df <- elections_cepesp(2018, type = "candidate", position = "President")

## End(Not run)

Download data on the candidates' background in local elections

Description

Download data on the candidates' background in local elections

Usage

elections_rda(year, level = "fed", archive = "candidate")

Arguments

year

Election year. For this function, only the years of 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available for local level. 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available for the federal level.

level

Election level podem ser fed (default) or local.

archive

Corresponds to one the following options: candidate, to download candidates' data; vote_mun_zone, to download electoral results; legend, to download data on parties' labels; party_mun_zone, to download electoral results by party; personal_finances, to download candidates' personal finances; details_mun_zone, to download data on the verification of elections; and seats, to download data on available seats.

Examples

## Not run: 
df <- elections_rda(2018)

## End(Not run)

Function for downloading electoral data from the TSE repository

Description

The elections_tse() function is a wrapper that allows users to download and clean electoral data from Brazil's TSE repository. This function provides data on candidates, electoral results, personal finances, and other election-related information from 1998 to 2024. The returned data.frame contains observations corresponding to candidates, cities, or electoral zones.

Usage

elections_tse(
  year,
  type,
  uf = "all",
  br_archive = FALSE,
  ascii = FALSE,
  encoding = "latin1",
  export = FALSE,
  temp = TRUE,
  data_table = FALSE,
  readme_pdf = FALSE
)

Arguments

year

Election year. Valid options are 1998, 2002, 2006, 2010, 2014, 2018, and 2022 for federal elections; and 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 for municipal elections.

type

Requested data type. Valid options are:

The elections_tse() function supports the following types of data downloads:

* candidate: Downloads data on the candidates. Each observation corresponds to a candidate. * candidate_add_infor: Downloads data on the candidates - Addtional information. Each observation corresponds to a candidate, available for 2024. * vote_mun_zone: Downloads data on the verification, disaggregated by cities and electoral zones. Each observation corresponds to a city/zone. * details_mun_zone: Downloads data on the details, disaggregated by town and electoral zone. Each observation corresponds to a town/zone. * legends: Downloads data on the party denomination (coalitions or parties), disaggregated by cities. Each observation corresponds to a city. * party_mun_zone: Downloads data on the polls by parties, disaggregated by cities and electoral zones. Each observation corresponds to a city/zone. * 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.

uf

Federation Unit acronym (character). In federal elections to obtain information about the president's position, insert the character "BR" in the parameter

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single file by setting this argument to TRUE (may not work for some elections and, in others, it only retrieves electoral data for presidential elections, which are absent in other files).

ascii

(logical). Should the text be transformed from Latin-1 to ASCII format?

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

export

(logical). Should the downloaded data be saved as .dta and .sav files in the current directory?

temp

(logical). If TRUE, keep the temporary files for future use (recommended).

data_table

should the returned object be a data.table? Defaults to FALSE.

readme_pdf

should the original README file be saved as a PDF in the working directory? Defaults to FALSE.

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

The elections_tse() function returns a data.frame with the requested electoral data.

elections_tse() returns a data.frame with the following variables:

Note

For elections prior to 2002, some information may be incomplete. For the 2014 and 2018 elections, additional columns are available. It is also important to note that in recent years, the TSE has changed the format of some data files, using CSV format with a header.

Examples

## Not run: 
# Download data on the candidates in the 2002 elections
cands <- elections_tse(2002, type = "candidate")

## End(Not run)

Download data on federal election coalitions in Brazil

Description

legend_fed() downloads and aggregates the data on the party denomination (coalitions or parties) from the federal elections in Brazil, disaggregated bi cities. The function returns a data.frame where each observation corresponds to a city.

Usage

legend_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

legend_fed() returns a data.frame.

Note

For elections prior to 2002, some information can be incomplete.

Examples

## Not run: 
df <- legend_fed(2002)

## End(Not run)

Download data on local election coalitions in Brazil

Description

legend_local() downloads and aggregates the party denominations (coalitions or parties) from the local elections in Brazil, disaggregated by cities. The function returns a data.frame where each observation corresponds to a city.

Usage

legend_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 2008, 2012, 2016, 2020, and 2024 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

legend_local() returns a data.frame.

Examples

## Not run: 
df <- legend_local(2000)

## End(Not run)

Download data on federal election coalitions in Brazil

Description

legends() downloads and aggregates the data on the party denomination (coalitions or parties) from the federal elections in Brazil, disaggregated bi cities. The function returns a data.frame where each observation corresponds to a city.

Usage

legends(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

legend_fed() returns a data.frame.

Note

For elections prior to 2002, some information can be incomplete.

Examples

## Not run: 
df <- legends(2002)

## End(Not run)

Returns a vector with the abbreviations of all Brazilian parties

Description

The character vector includes only parties that ran in elections from 1994 to 2022.

Usage

parties_br(year)

Arguments

year

Election year (integer). For this function, only from 1994 to 2022 are available.

Examples

## Not run: 
parties_election2002 <- parties_br(2002)

## End(Not run)

Download data on the polls by parties from federal elections in Brazil

Description

party_mun_zone() downloads and aggregates the data on the polls by parties from the federal elections in Brazil, disaggregated by cities and electoral zones. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

party_mun_zone(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Filter results by Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

party_mun_zone() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.

Examples

## Not run: 
df <- party_mun_zone(2002)

## End(Not run)

Download data on the polls by parties from federal elections in Brazil

Description

party_mun_zone_fed() downloads and aggregates the data on the polls by parties from the federal elections in Brazil, disaggregated by cities and electoral zones. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

party_mun_zone_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Filter results by Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

party_mun_zone_fed() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.

Examples

## Not run: 
df <- party_mun_zone_fed(2002)

## End(Not run)

Download data on the polls by parties from local elections in Brazil

Description

party_mun_zone_local() downloads and aggregates data on the polls by parties from local elections in Brazil, disaggregated by electoral zone. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

party_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

party_mun_zone_local() returns a data.frame.

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- party_mun_zone_local(2000)

## End(Not run)

Download data on federal candidates' personal financial disclosures

Description

personal_finances() downloads and aggregates the data on federal candidates' personal financial disclosures. The function returns a data.frame where each observation corresponds to a candidate's property.

Usage

personal_finances(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 2006, 2010, 2014, 2018, 2022 and 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

personal_finances() returns a data.frame.

Note

For the elections prior to 2000, some information may be incomplete.

Examples

## Not run: 
df <- personal_finances(2006)

## End(Not run)

Download data on federal candidates' personal financial disclosures

Description

personal_finances_local() downloads and aggregates the data on federal candidates' personal financial disclosures. The function returns a data.frame where each observation corresponds to a candidate's property.

Usage

personal_finances_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

personal_finances_fed() returns a data.frame.

Note

For the elections prior to 2000, some information may be incomplete.

Examples

## Not run: 
df <- personal_finances_fed(2006)

## End(Not run)

Download data on local candidates' personal financial disclosures

Description

personal_finances_local() downloads and aggregates the data on local candidates' personal financial disclosures. The function returns a data.frame where each observation corresponds to a candidate's property.

Usage

personal_finances_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

assets_candidate_local() returns a data.frame.

Note

For the elections prior to 2000, some information may be incomplete.

Examples

## Not run: 
df <- personal_finances_local(2000)

## End(Not run)

Download data on the number of seats under dispute in federal elections

Description

seats() downloads and aggregates data on the number of seats under dispute in federal elections in Brazil. The function returns a tbl, data.frame where each observation corresponds to a district-office dyad.

Usage

seats(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years of 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE keep temporary compressed file

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

seats() returns a data.frame.

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- seats(2000)

## End(Not run)

Download data on the number of seats under dispute in federal elections

Description

seats_fed() downloads and aggregates data on the number of seats under dispute in federal elections in Brazil. The function returns a tbl, data.frame where each observation corresponds to a district-office dyad.

Usage

seats_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years of 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE keep temporary compressed file

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

seats_fed() returns a data.frame with the following variables:

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- seats_fed(2000)

## End(Not run)

Download data on the number of seats under dispute in local elections

Description

seats_local() downloads and aggregates data on the number of seats under dispute in local elections in Brazil. The function returns a tbl, data.frame where each observation corresponds to a municipality office dyad.

Usage

seats_local(year, uf = "all", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years of 1996, 2000, 2004, 2008, 2012, 2016, 2020 and 2024 are available.

uf

Federation Unit acronym (character vector).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

seats_local() returns a data.frame.

Note

For the elections prior to 2000, some information can be incomplete.

Examples

## Not run: 
df <- seats_local(2000)

## End(Not run)

Download data on the candidates' social media links in federal elections

Description

social_media() is a function that allows you to download data on the social media handles of candidates participating in federal and municipal elections in Brazil. The function returns a data.frame where each observation corresponds to a candidate's social media handles (i.e., usernames).

Usage

social_media(year, encoding = "latin1", temp = TRUE, readme_pdf = FALSE)

Arguments

year

Election year (integer). For this function, only the years 2020, 2022, and 2024 are available.

encoding

Data original encoding (defaults to 'latin1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). Whether to keep the temporary data files for future use (recommended).

readme_pdf

should the original README file be saved as a PDF in the working directory? Defaults to FALSE.

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

social_media() returns a tbl, data.frame.

Examples

## Not run: 
df <- social_media(2022)

## End(Not run)

Returns a vector with the abbreviations of all Brazilian states

Description

Returns a vector with the abbreviations of all Brazilian states

Usage

uf_br()

Download data on candidate electoral results in federal elections in Brazil

Description

vote_mun_zone() downloads and aggregates data on the verification of federal elections in Brazil, disaggregated by cities and electoral zone. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

vote_mun_zone(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

vote_mun_zone() returns a data.frame with the following variables:

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, 2022, and 2024 elections, more variable are available.

Examples

## Not run: 
df <- vote_mun_zone(2002)

## End(Not run)

Download data on candidate electoral results in federal elections in Brazil

Description

vote_mun_zone_fed() downloads and aggregates data on the verification of federal elections in Brazil, disaggregated by cities and electoral zone. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

vote_mun_zone_fed(
  year,
  uf = "all",
  br_archive = FALSE,
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector).

br_archive

In the TSE's data repository, some results can be obtained for the whole country by loading a single within a single file by setting this argument to TRUE (may not work in for some elections and, in other, it recovers only electoral data for presidential elections, absent in other files).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

vote_mun_zone_fed() returns a data.frame with the following variables:

Note

For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.

Examples

## Not run: 
df <- vote_mun_zone_fed(2002)

## End(Not run)

Download data on candidate electoral results in local elections in Brazil

Description

vote_mun_zone_local() downloads and aggregates data on the verification from local elections in Brazil, disaggregated by electoral zone. The function returns a data.frame where each observation corresponds to a city/zone.

Usage

vote_mun_zone_local(
  year,
  uf = "all",
  ascii = FALSE,
  encoding = "latin1",
  export = FALSE,
  temp = TRUE
)

Arguments

year

Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available.

uf

Federation Unit acronym (character vector).

ascii

(logical). Should the text be transformed from Latin-1 to ASCII format?

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

export

(logical). Should the downloaded data be saved in .dta and .sav in the current directory?

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

vote_mun_zone_local() returns a data.frame with the following variables:

  • DATA_GERACAO: Generation date of the file (when the data was collected).

  • HORA_GERACAO: Generation time of the file (when the data was collected), Brasilia Time.

  • ANO_ELEICAO: Election year.

  • NUM_TURNO: Round number.

  • DESCRICAO_ELEICAO: Description of the election.

  • SIGLA_UF: Units of the Federation's acronym in which occurred the election.

  • SIGLA_UE: Units of the Federation's acronym (In case of major election is the FU's acronym in which the candidate runs for (text) and in case of municipal election is the municipal's Supreme Electoral Court code (number)). Assume the special values BR, ZZ and VT to designate, respectively, Brazil, Overseas and Absentee Ballot.

  • CODIGO_MUNICIPIO: Supreme Electoral code from the city where occurred the election.

  • NOME_MUNICIPIO: Name of the city where occurred the election.

  • NUMERO_ZONA: Zone number.

  • CODIGO_CARGO: Code of the position that the candidate runs for.

  • NUMERO_CANDIDATO: Candidate's number in the ballot box.

  • SQ_CANDIDATO: Candidate's sequence number generated internally by the electoral

  • NOME_CANDIDATO: Candidate's complete name.

  • NOME_URNA_CANDIDATO: Candidate's ballot box name.

  • DESCRICAO_CARGO: Description of the position that the candidate runs for.

  • COD_SIT_CAND_TOT: Candidate's totalization status code in that election round.

  • NUMERO_PARTIDO: Party number.

  • SIGLA_PARTIDO: Party's acronym.

  • NOME_PARTIDO: Party name.

  • SEQUENCIAL_LEGENDA: Coalition's sequential number, generated internally by the electoral justice.

  • NOME_COLIGACAO: Coalition name.

  • COMPOSICAO_LEGENDA: Coalition's composition.

  • TOTAL_VOTOS: Total of votes.

  • TRANSITO: Electoral result outside the candidates' district? (N for no).

Note

For the elections prior to 2000, some information can be incomplete.

See Also

vote_mun_zone_fed for federal elections in Brazil.

Examples

## Not run: 
df <- vote_mun_zone_local(2000)

## End(Not run)

Download data on candidate electoral results in federal elections in Brazil by electoral section

Description

vote_section() downloads and cleans data on the verification of federal elections in Brazil, disaggregated by electoral section. Different from other electionsBR's functions, results are only extract for individual states, one at a time. The function returns a data.frame where each observation corresponds to an electoral section in a given Brazilian state.

Usage

vote_section(
  year,
  uf = "AC",
  encoding = "latin1",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available.

uf

Federation Unit acronym (character vector). Defaults to 'AC' (Acre).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original file

Details

If export is set to TRUE, the data is saved as .dta and .sav files in the working directory.

Value

vote_section() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete.

Examples

## Not run: 
df <- vote_section(2002)

## End(Not run)

Download data on candidate electoral results in federal elections in Brazil by electoral section

Description

vote_section_fed() downloads and cleans data on the verification of federal elections in Brazil, disaggregated by electoral section. Different from other electionsBR's functions, results are only extract for individual states, one at a time. The function returns a data.frame where each observation corresponds to an electoral section in a given Brazilian state.

Usage

vote_section_fed(year, uf = "AC", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available.

uf

Federation Unit acronym (character vector). Defaults to 'AC' (Acre).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the data is saved as .dta and .sav files in the working directory.

Value

vote_section_fed() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete.

Examples

## Not run: 
df <- vote_section_fed(2002)

## End(Not run)

Download data on candidate electoral results in local elections in Brazil by electoral section

Description

vote_section_local() downloads and cleans data on the verification of local elections in Brazil, disaggregated by electoral section. Different from other electionsBR's functions, results are only extract for individual states, one at a time. The function returns a data.frame where each observation corresponds to an electoral section in a given Brazilian state.

Usage

vote_section_local(year, uf = "AC", encoding = "latin1", temp = TRUE)

Arguments

year

Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024 are available.

uf

Federation Unit acronym (character vector). Defaults to 'AC' (Acre).

encoding

Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

Details

If export is set to TRUE, the data is saved as .dta and .sav files in the working directory.

Value

vote_section_local() returns a data.frame.

Note

For the elections prior to 2002, some information can be incomplete.

Examples

## Not run: 
df <- vote_section_local(2000)

## End(Not run)

Download data on the voters' profile

Description

voter_profile() downloads and cleans data on the voters' profile aggregated by state, city and electoral zone. The function returns a data.frame where each observation corresponds to a voter profile type.

Usage

voter_profile(year, encoding = "windows-1252", temp = TRUE, readme_pdf = FALSE)

Arguments

year

Election year (integer). For this function, the following years are available: 1998, 2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022, and 2024.

encoding

Data original encoding (defaults to 'windows-1252'). This can be changed to avoid errors when ascii = TRUE. #'

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

voter_profile() returns a data.frame.

Examples

## Not run: 
df <- voter_profile(2002)

## End(Not run)

Download data on the voters' profile by vote section

Description

voter_profile_by_section() downloads and cleans data on the voters' profile aggregated by voting section (i.e., voting stations). The function returns a data.frame where each observation corresponds to a voter profile type.

Usage

voter_profile_by_section(
  year,
  uf = "AC",
  encoding = "windows-1252",
  temp = TRUE,
  readme_pdf = FALSE
)

Arguments

year

Election year (integer). For this function, the following years are available: 2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022 and 2024.

uf

Federation Unit acronym (character vector). Defaults to 'AC' (Acre).

encoding

Data original encoding (defaults to 'windows-1252'). This can be changed to avoid errors when ascii = TRUE.

temp

(logical). If TRUE, keep the temporary compressed file for future use (recommended)

readme_pdf

original readme

Details

If export is set to TRUE, the downloaded data is saved as .dta and .sav files in the current directory.

Value

voter_profile() returns a data.frame with the following variables:

Examples

## Not run: 
df <- voter_profile_by_section(2016)

## End(Not run)