-
-
Save gabrielzanlorenssi/0878e1f4c057135753212cf3d7b66e04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##-- GABRIEL ZANLORENSSI | |
##-- 01/04/2020 | |
# Bibliotecas ------------------------------------------------------------- | |
library(readxl) | |
library(tidyverse) | |
library(lubridate) | |
# Gráficos ---------------------------------------------------------------- | |
audiencia <- read_excel("audiencia2.xlsx") | |
glimpse(audiencia) | |
#bservations: 266 | |
#Variables: 4 | |
#$ Dia <dttm> 2020-03-31, 2020-03-31, 2020-03-31, 2020-03-31, 2020-03-31, 2020… | |
#$ Horário <chr> "23h59", "23h46", "23h35", "23h23", "23h06", "22h51", "22h35", "2… | |
#$ Empresa <chr> "Globo", "Globo", "Globo", "Globo", "Globo", "Globo", "Globo", "G… | |
#$ Audiência <dbl> 30.5, 30.1, 28.5, 29.5, 29.8, 36.6, 32.3, 34.3, 31.9, 30.9, 32.7,… | |
#-- total | |
audiencia %>% | |
mutate(Empresa = factor(Empresa, | |
levels=rev(c("Globo", "Record", | |
"SBT", "Band", "RedeTV", | |
"Cultura", "Gazeta")))) %>% | |
mutate(Horário = ymd_hms(paste0(Dia, " ", Horário, "m00s"))) %>% | |
ggplot(aes(x=Horário, y=Audiência)) + | |
geom_area(aes(fill=Empresa), alpha=0.8, position="fill") + | |
geom_vline(xintercept = ymd_hms("2020-03-31 22h42m00s"), | |
linetype="dashed") + | |
geom_vline(xintercept = ymd_hms("2020-04-01 00h21m00s"), | |
linetype="dashed") + | |
ggthemes::theme_fivethirtyeight(base_size=14) + | |
scale_fill_manual(values = c("#C4C4C4", | |
"#838383", | |
"#464747", | |
"#21923F", | |
"#C3902C", | |
"#C33D2C", | |
"#284583")) + | |
scale_y_continuous(labels=scales::percent) + | |
geom_text(data=data.frame(x=1), label="BBB 20", angle=90, | |
x=ymd_hms("2020-03-31 22h25m00s"), y=0.5) + | |
labs(title = "Audiência da TV aberta no dia 31/03/2020", | |
subtitle = "@gzanlorenssi", | |
caption = "Nota: dados apenas de São Paulo. \n | |
Fonte: Bastidores da TV/IBOPE") + | |
theme(axis.title = element_text()) + ylab('Percentual da audiência') | |
#-- relativo | |
audiencia %>% | |
mutate(Empresa = factor(Empresa, | |
levels=rev(c("Globo", "Record", | |
"SBT", "Band", "RedeTV", | |
"Cultura", "Gazeta")))) %>% | |
mutate(Horário = ymd_hms(paste0(Dia, " ", Horário, "m00s"))) %>% | |
ggplot(aes(x=Horário, y=Audiência)) + | |
geom_step(aes(col=Empresa), alpha=0.8, size=1.5) + | |
geom_vline(xintercept = ymd_hms("2020-03-31 22h42m00s"), | |
linetype="dashed") + | |
geom_vline(xintercept = ymd_hms("2020-04-01 00h21m00s"), | |
linetype="dashed") + | |
ggthemes::theme_fivethirtyeight(base_size=14) + | |
scale_color_manual(values = c("#C4C4C4", | |
"#838383", | |
"#464747", | |
"#21923F", | |
"#C3902C", | |
"#C33D2C", | |
"#284583")) + | |
geom_text(data=data.frame(x=1), label="BBB 20", angle=90, | |
x=ymd_hms("2020-03-31 22h25m00s"), y=20) + | |
labs(title = "Audiência da TV aberta no dia 31/03/2020", | |
subtitle = "@gzanlorenssi", | |
caption = "Nota: dados apenas de São Paulo. \n | |
Fonte: Bastidores da TV/IBOPE") + | |
theme(axis.title = element_text()) + ylab('Pontos') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment