library(tidyverse)
library(knitr)
install.packages("devtools")
library(devtools)
devtools::install_github("Cepesp-Fgv/cepesp-r")
library(cepespR)
data <- cepespdata(year=2016, position="Prefeito", regional_aggregation="Municipality",political_aggregation="Candidate")
On average, how many people voted in any municipality in the first round of the 2016 election?
What percentage of the votes cast in each region (NOME_MACRO
) of the country were won by PMDB prefeito candidates?
Now compare the previous result to the percentage of elected prefeitos (DESC_SIT_TOT_TURNO
) who were from the PMDB in each region.
How do male candidates differ from female candidates (DESCRICAO_SEXO
)? Compare averages on two variables: The number of votes (QTDE_VOTOS
) and age (IDADE_DATA_ELEICAO
). Report the averages in a simple table. Hint: Remember to use summarise_at
.
Conduct a t-test to assess if women prefeitos receive a statistically different quantity of votes to men. Report a simple table of the results. Hint: Remember the tidy()
action after a messy statistical test.
Conduct a difference-in-means t-test between men and women of both number of votes and age at the same time. Report the p-values of each t-test.
Create a neat, well-labelled, table of the average age of elected prefeitos in each region (NOME_MACRO
) and by gender (DESCRICAO_SEXO
). The table should have regions in the rows and gender in the columns.
Are married candidates (DESCRICAO_ESTADO_CIVIL
) for prefeito more likely to be elected than unmarried (all groups except married) candidates? Provide a well-formatted, labelled, table.