pollingBR

pollingBR was created to give an easier access to data from the data repository of electoral polls from Poder360's news website. The package facilitates extraction of information from the open data API - developed by Volt Data Lab - of this repository.

The package has four main functions, all with similar arguments. Each of them correspond to one of the offices for which there are electoral polls in the data repository:

Besides those main functions, the package also includes:

Instalando e carregando o pacote

No momento, o pacote pollingBR pode ser instalado diretamente da sua página no github:

if (!require("devtools")) install.packages("devtools")
devtools::install_github("voltdatalab/pollingBR")

Assim como os demais pacotes em R, uma vez instalado, ele deve ser carregado com a função library().

library(pollingBR)

Main functions

Those four functions that extract estimates of electoral polls for president, governor, senator and mayor have a similar basic structure. All of them return a dataframe in which each line has the estimate for a candidate in a certain electoral poll. They have four arguments: year, state, type and round (except for the senator() which does not include this last one).

# Extract data for all polls presidential polls in the 2018 elections
president_2018 <- president(2018)

# Get data for all gubernatorial polls in the 2014 elections
governor_2014 <- governor(2014)
# Extract data for all national-level polls for president in 2014
president_br_2014 <- president(2014, state = "BR")

# Get data for all senatorial polls in Brazilian southern states in 2010
senate_south_2010 <- senator(2010, state = c("RS", "SC", "PR"))
# Obtem dados de respostas espontaneas e estimuladas para pesquisas para o senado em SP no ano de 2006
senate_sp_2006 <- senator(2006, state = "SP", type = c(1, 2))

# Extrai dados de respostas de rejeicao em pesquisas nacionais para presidente em 2018
president_rejection_2018 <- president(2018, state = "BR", type = 3)
# Extract data from all stimulated responses for polls in the first round of mayoral elections in 2012
mayor_2012_1r <- mayor(2012, type = 2, round = 1)

Other functions

The get_cities() function returns a data.frame with a complete list of the cities with mayoral electoral polls in Poder360's data repository, accompanied by the election years for which they are available. Thus, users have an easier access to which municipal polls are available for them.

In the following example, we can see the first six lines of this data frame, showing that there are polls available for the mayoral races in the cities of Cruzeiro do Sul (only in 2008) and Rio Branco (in the election years between 2000 and 2016).

cities_polls <- get_cities()
head(cities_polls)


voltdatalab/pollingbr documentation built on April 1, 2021, 4:38 a.m.