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 |
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.
To learn more about electionsBR, check the package vignette and documentation.
Beatriz Costa (UFMG/Brazil) [ctb], Fernando Meireles (UFMG/Brazil) [author], Denisson Silva (UFMG/Brazil) [author]
Useful links:
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.
candidate( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
candidate( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year ( |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'latin1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
candidate
returns a tbl, data.frame
with the following variables:
For the elections prior to 2002, some information can be incomplete. For the 2014 and 2018 elections, more variables are available.
## Not run: df <- candidate(2002) ## End(Not run)
## Not run: df <- candidate(2002) ## End(Not run)
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.
candidate_add_infor( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
candidate_add_infor( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year ( |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'latin1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
candidate_add_infor
returns a tbl, data.frame
with the following variables:
For the elections prior to 2024.
## Not run: df <- candidate_add_infor(2024) ## End(Not run)
## Not run: df <- candidate_add_infor(2024) ## End(Not run)
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.
candidate_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
candidate_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
year |
Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'latin1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
candidate_local()
returns a data.frame
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variables are available.
## Not run: df <- candidate_fed(2000) ## End(Not run)
## Not run: df <- candidate_fed(2000) ## End(Not run)
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.
candidate_local(year, uf = "all", encoding = "latin1", temp = TRUE)
candidate_local(year, uf = "all", encoding = "latin1", temp = TRUE)
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 ( |
encoding |
Data original encoding (defaults to 'latin1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
candidate_local()
returns a data.frame
with the following variables:
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- candidate_local(2000) ## End(Not run)
## Not run: df <- candidate_local(2000) ## End(Not run)
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.
details_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
details_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, 202. 2024 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
details_mun_zone()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, 2022 and 2024 elections, more variables are available.
## Not run: df <- details_mun_zone(2002) ## End(Not run)
## Not run: df <- details_mun_zone(2002) ## End(Not run)
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.
details_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
details_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
year |
Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
details_mun_zone_fed()
returns a data.frame
with the following variables:
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variables are available.
## Not run: df <- details_mun_zone_fed(2002) ## End(Not run)
## Not run: df <- details_mun_zone_fed(2002) ## End(Not run)
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.
details_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)
details_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016 and 2020 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
details_mun_zone_local()
returns a data.frame
with the following variables:
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- details_mun_zone_local(2000) ## End(Not run)
## Not run: df <- details_mun_zone_local(2000) ## End(Not run)
Retrieve electoral data from the cepesp API.
elections_cepesp(year, type, position, data_table = FALSE)
elections_cepesp(year, type, position, data_table = FALSE)
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. |
The function returns a tibble containing the requested elections data.
The function is a wrapper for the cepesp API. To learn more about the API, please visit cepespdata.io.
## Not run: df <- elections_cepesp(2018, type = "candidate", position = "President") ## End(Not run)
## Not run: df <- elections_cepesp(2018, type = "candidate", position = "President") ## End(Not run)
Download data on the candidates' background in local elections
elections_rda(year, level = "fed", archive = "candidate")
elections_rda(year, level = "fed", archive = "candidate")
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: |
## Not run: df <- elections_rda(2018) ## End(Not run)
## Not run: df <- elections_rda(2018) ## End(Not run)
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.
elections_tse( year, type, uf = "all", br_archive = FALSE, ascii = FALSE, encoding = "latin1", export = FALSE, temp = TRUE, data_table = FALSE, readme_pdf = FALSE )
elections_tse( year, type, uf = "all", br_archive = FALSE, ascii = FALSE, encoding = "latin1", export = FALSE, temp = TRUE, data_table = FALSE, readme_pdf = FALSE )
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 * |
uf |
Federation Unit acronym ( |
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 |
ascii |
( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
export |
( |
temp |
( |
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. |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
The elections_tse()
function returns a data.frame
with the requested electoral data.
elections_tse()
returns a data.frame
with the following variables:
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.
## Not run: # Download data on the candidates in the 2002 elections cands <- elections_tse(2002, type = "candidate") ## End(Not run)
## Not run: # Download data on the candidates in the 2002 elections cands <- elections_tse(2002, type = "candidate") ## End(Not run)
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.
legend_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
legend_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
year |
Election year. For this function, only the years 1994, 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
legend_fed()
returns a data.frame
.
For elections prior to 2002, some information can be incomplete.
## Not run: df <- legend_fed(2002) ## End(Not run)
## Not run: df <- legend_fed(2002) ## End(Not run)
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.
legend_local(year, uf = "all", encoding = "latin1", temp = TRUE)
legend_local(year, uf = "all", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 2008, 2012, 2016, 2020, and 2024 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
legend_local()
returns a data.frame
.
## Not run: df <- legend_local(2000) ## End(Not run)
## Not run: df <- legend_local(2000) ## End(Not run)
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.
legends( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
legends( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
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 ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
legend_fed()
returns a data.frame
.
For elections prior to 2002, some information can be incomplete.
## Not run: df <- legends(2002) ## End(Not run)
## Not run: df <- legends(2002) ## End(Not run)
The character vector includes only parties that ran in elections from 1994 to 2022.
parties_br(year)
parties_br(year)
year |
Election year ( |
## Not run: parties_election2002 <- parties_br(2002) ## End(Not run)
## Not run: parties_election2002 <- parties_br(2002) ## End(Not run)
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.
party_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
party_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
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 ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
party_mun_zone()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.
## Not run: df <- party_mun_zone(2002) ## End(Not run)
## Not run: df <- party_mun_zone(2002) ## End(Not run)
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.
party_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
party_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
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 ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
party_mun_zone_fed()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.
## Not run: df <- party_mun_zone_fed(2002) ## End(Not run)
## Not run: df <- party_mun_zone_fed(2002) ## End(Not run)
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.
party_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)
party_mun_zone_local(year, uf = "all", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
party_mun_zone_local()
returns a data.frame
.
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- party_mun_zone_local(2000) ## End(Not run)
## Not run: df <- party_mun_zone_local(2000) ## End(Not run)
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.
personal_finances( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
personal_finances( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year. For this function, only the years 2006, 2010, 2014, 2018, 2022 and 2024 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
personal_finances()
returns a data.frame
.
For the elections prior to 2000, some information may be incomplete.
## Not run: df <- personal_finances(2006) ## End(Not run)
## Not run: df <- personal_finances(2006) ## End(Not run)
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.
personal_finances_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
personal_finances_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
year |
Election year. For this function, only the years 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
personal_finances_fed()
returns a data.frame
.
For the elections prior to 2000, some information may be incomplete.
## Not run: df <- personal_finances_fed(2006) ## End(Not run)
## Not run: df <- personal_finances_fed(2006) ## End(Not run)
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.
personal_finances_local(year, uf = "all", encoding = "latin1", temp = TRUE)
personal_finances_local(year, uf = "all", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
assets_candidate_local()
returns a data.frame
.
For the elections prior to 2000, some information may be incomplete.
## Not run: df <- personal_finances_local(2000) ## End(Not run)
## Not run: df <- personal_finances_local(2000) ## End(Not run)
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.
seats( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
seats( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
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 ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
seats()
returns a data.frame
.
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- seats(2000) ## End(Not run)
## Not run: df <- seats(2000) ## End(Not run)
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.
seats_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
seats_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE )
year |
Election year. For this function, only the years of 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
seats_fed()
returns a data.frame
with the following variables:
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- seats_fed(2000) ## End(Not run)
## Not run: df <- seats_fed(2000) ## End(Not run)
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.
seats_local(year, uf = "all", encoding = "latin1", temp = TRUE)
seats_local(year, uf = "all", encoding = "latin1", temp = TRUE)
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 ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
seats_local()
returns a data.frame
.
For the elections prior to 2000, some information can be incomplete.
## Not run: df <- seats_local(2000) ## End(Not run)
## Not run: df <- seats_local(2000) ## End(Not run)
Returns a vector with the abbreviations of all Brazilian states
uf_br()
uf_br()
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.
vote_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
vote_mun_zone( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
vote_mun_zone()
returns a data.frame
with the following variables:
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, 2022, and 2024 elections, more variable are available.
## Not run: df <- vote_mun_zone(2002) ## End(Not run)
## Not run: df <- vote_mun_zone(2002) ## End(Not run)
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.
vote_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
vote_mun_zone_fed( year, uf = "all", br_archive = FALSE, encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
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 |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
vote_mun_zone_fed()
returns a data.frame
with the following variables:
For the elections prior to 2002, some information can be incomplete. For the 2014, 2018, and 2022 elections, more variable are available.
## Not run: df <- vote_mun_zone_fed(2002) ## End(Not run)
## Not run: df <- vote_mun_zone_fed(2002) ## End(Not run)
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.
vote_mun_zone_local( year, uf = "all", ascii = FALSE, encoding = "latin1", export = FALSE, temp = TRUE )
vote_mun_zone_local( year, uf = "all", ascii = FALSE, encoding = "latin1", export = FALSE, temp = TRUE )
year |
Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, and 2024 are available. |
uf |
Federation Unit acronym ( |
ascii |
( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
export |
( |
temp |
( |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
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).
For the elections prior to 2000, some information can be incomplete.
vote_mun_zone_fed
for federal elections in Brazil.
## Not run: df <- vote_mun_zone_local(2000) ## End(Not run)
## Not run: df <- vote_mun_zone_local(2000) ## End(Not run)
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.
vote_section( year, uf = "AC", encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
vote_section( year, uf = "AC", encoding = "latin1", temp = TRUE, readme_pdf = FALSE )
year |
Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, 2022 and 2024 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original file |
If export is set to TRUE
, the data is saved as .dta and .sav
files in the working directory.
vote_section()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete.
## Not run: df <- vote_section(2002) ## End(Not run)
## Not run: df <- vote_section(2002) ## End(Not run)
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.
vote_section_fed(year, uf = "AC", encoding = "latin1", temp = TRUE)
vote_section_fed(year, uf = "AC", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 1998, 2002, 2006, 2010, 2014, 2018, and 2022 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the data is saved as .dta and .sav
files in the working directory.
vote_section_fed()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete.
## Not run: df <- vote_section_fed(2002) ## End(Not run)
## Not run: df <- vote_section_fed(2002) ## End(Not run)
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.
vote_section_local(year, uf = "AC", encoding = "latin1", temp = TRUE)
vote_section_local(year, uf = "AC", encoding = "latin1", temp = TRUE)
year |
Election year. For this function, only the years 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024 are available. |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'Latin-1'). This can be changed to avoid errors
when |
temp |
( |
If export is set to TRUE
, the data is saved as .dta and .sav
files in the working directory.
vote_section_local()
returns a data.frame
.
For the elections prior to 2002, some information can be incomplete.
## Not run: df <- vote_section_local(2000) ## End(Not run)
## Not run: df <- vote_section_local(2000) ## End(Not run)
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.
voter_profile(year, encoding = "windows-1252", temp = TRUE, readme_pdf = FALSE)
voter_profile(year, encoding = "windows-1252", temp = TRUE, readme_pdf = FALSE)
year |
Election year ( |
encoding |
Data original encoding (defaults to 'windows-1252'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
voter_profile()
returns a data.frame
.
## Not run: df <- voter_profile(2002) ## End(Not run)
## Not run: df <- voter_profile(2002) ## End(Not run)
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.
voter_profile_by_section( year, uf = "AC", encoding = "windows-1252", temp = TRUE, readme_pdf = FALSE )
voter_profile_by_section( year, uf = "AC", encoding = "windows-1252", temp = TRUE, readme_pdf = FALSE )
year |
Election year ( |
uf |
Federation Unit acronym ( |
encoding |
Data original encoding (defaults to 'windows-1252'). This can be changed to avoid errors
when |
temp |
( |
readme_pdf |
original readme |
If export is set to TRUE
, the downloaded data is saved as .dta and .sav
files in the current directory.
voter_profile()
returns a data.frame
with the following variables:
## Not run: df <- voter_profile_by_section(2016) ## End(Not run)
## Not run: df <- voter_profile_by_section(2016) ## 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 adata.frame
where each observation corresponds to a candidate's social media handles (i.e., usernames).Usage
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 atbl, data.frame
.Examples