View source: R/elections_tse.R
elections_tse | R Documentation |
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 2022. 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
)
year |
Election year. Valid options are 1998, 2002, 2006, 2010, 2014, 2018, and 2022 for federal elections; and 1996, 2000, 2004, 2008, 2012, 2016, and 2020 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.