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,
  ascii = FALSE, encoding = "latin1", export = FALSE)



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


Filter results by Federation Unit acronym (character vector).


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 recoverns only electoral data for presidential elections, absent in other files).


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


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


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


party_mun_zone_fed() 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.

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

  • TIPO_LEGENDA: It informs it the candidate runs for 'coalition' or 'isolated party'.

  • NOME_COLIGACAO: Coalition name.

  • COMPOSICAO_LEGENDA: Coalition's composition.

  • NUMERO_PARTIDO: Party number.

  • SIGLA_PARTIDO: Party's acronym.

  • NOME_PARTIDO: Party name.

  • QTDE_VOTOS_NOMINAIS: Total number of nominal votes that a party received in that city and zone.

  • QTDE_VOTOS_LEGENDA: Total number of votes that a coalitions received in that city and zone.

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

  • TRANSITO: It informs whether the record relates or not to absentee ballot votes (only for 2014 election).

From 2018 on, some new variables are also available:

  • COD_TIPO_ELEICAO: Election type code.

  • NOME_TIPO_ELEICAO: Election type.

  • COD_ELEICAO: Election code.

  • DATA_ELEICAO: Election date.

  • ABRANGENCIA: Election scope.

  • NOME_UE: Electoral unit name.


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


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

See also

party_mun_zone_local for local elections in Brazil.


df <- party_mun_zone_fed(2002)
# }