Leitura e Limpeza do Banco de dados

library(tidyverse) #Pacote importante
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(data.table)#Pacote para leitura de dados
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose
#########Leitura e Limpeza dos Dados########
df <- fread("MICRODADOS_ENCCEJA_NACIONAL_REGULAR_2020.csv",
            encoding = "Latin-1",
            nrows = 10000)

df <- df %>% select(-c(1,2,6,17:20,29:36))

Lemos os dados do Encceja 2020, agora, desejamos construir alguns gráficos, por exemplo, o gráfico que apresenta o número de candidato ao Encceja por unidade federativa:

##################Graficos#################

###UF

UF <- df %>% 
  group_by(SG_UF_PROVA) %>% 
  summarise(Quant=n())

UF %>% ggplot(aes(reorder(SG_UF_PROVA, -Quant), Quant, fill=SG_UF_PROVA)) + 
  geom_col(show.legend = FALSE) + 
  geom_text(aes(label=Quant), cex=3, vjust=-0.5)+
  labs(title = "Candidatos ao Encceja 2020 por Unidade Federativa",
       subtitle = "Fonte: INEP",
       caption = "Autor: Fernando de Souza Bastos")+
  ylab("Número de Candidatos")+
  xlab("Unidade Federativa")+
  theme_minimal()