data <- query_octavos(hs_query = "(/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND time_created:[2017-01-01 TO 2018-12-31]", stt_query = "(/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]", il_query = "(/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]",yle_query="(/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]") %>% filter(media!="YLE")
data2 <- query_octavos(hs_query = "(/W=.*[Tt]utkij.*/ OR /W=.*[Tt]utkimu.*/ OR /W=.*[Pp]rofessor.*/ OR /W=.*[Ss]elvity.*/ OR /W=.*[Rr]aportt?i.*/ OR /W=.*[Tt]ilasto.*/) AND (/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND time_created:[2017-01-01 TO 2018-12-31]", stt_query = "(/W=.*[Tt]utkij.*/ OR /W=.*[Tt]utkimu.*/ OR /W=.*[Pp]rofessor.*/ OR /W=.*[Ss]elvity.*/ OR /W=.*[Rr]aportt?i.*/ OR /W=.*[Tt]ilasto.*/) AND (/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]", il_query = "(/W=.*[Tt]utkij.*/ OR /W=.*[Tt]utkimu.*/ OR /W=.*[Pp]rofessor.*/ OR /W=.*[Ss]elvity.*/ OR /W=.*[Rr]aportt?i.*/ OR /W=.*[Tt]ilasto.*/) AND (/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]",yle_query="(/W=.*[Tt]utkij.*/ OR /W=.*[Tt]utkimu.*/ OR /W=.*[Pp]rofessor.*/ OR /W=.*[Ss]elvity.*/ OR /W=.*[Rr]aportt?i.*/ OR /W=.*[Tt]ilasto.*/) AND (/W=[Aa]lkoholila.*/ OR /W=[Aa]lkoholipol.*/) AND timePublished:[2017-01-01 TO 2018-12-31]") %>% filter(media!="YLE")
weeks <- tibble(week=floor_date(ymd("2017-01-01"),"week") + weeks(0:(2*52))) %>% full_join(tibble(media=c("HS","STT","IL")),by=character())
months <- tibble(month=ymd("2017-01-01") + months(0:(2*12-1))) %>% full_join(tibble(media=c("HS","STT","IL")),by=character())
ggplot(data,aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_point(data=data %>% count(date,name="articles"),aes(color="daily")) +
geom_step(data=data %>% count(date=week,name="articles") %>% right_join(weeks %>% distinct(week),by=c("date"="week")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,weeks(1)),aes(color="weekly")) +
geom_step(data=data %>% count(date=month,name="articles") %>% right_join(months %>% distinct(month),by=c("date"="month")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,months(1)),aes(color="monthly"))

ggplot(data,aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
facet_wrap(~fct_relevel(media,"HS","STT","IL"),ncol=1) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_point(data=data %>% count(media,date,name="articles"),aes(color="daily")) +
geom_step(data=data %>% count(media,date=week,name="articles") %>% right_join(weeks,by=c("date"="week","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,weeks(1)),aes(color="weekly")) +
geom_step(data=data %>% count(media,date=month,name="articles") %>% right_join(months,by=c("date"="month","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,months(1)),aes(color="monthly"))

ggplot(mapping=aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_step(data=data %>% count(date=month,name="articles") %>% right_join(months %>% distinct(month),by=c("date"="month")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,months(1)),aes(color="main")) +
geom_step(data=data2 %>% count(date=month,name="articles") %>% right_join(months %>% distinct(month),by=c("date"="month")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,months(1)),aes(color="sub"))

ggplot(mapping=aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
facet_wrap(~fct_relevel(media,"HS","STT","IL"),ncol=1) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_step(data=data %>% count(media,date=month,name="articles") %>% right_join(months,by=c("date"="month","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,months(1)),aes(color="main")) +
geom_step(data=data2 %>% count(media,date=month,name="articles") %>% right_join(months,by=c("date"="month","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,months(1)),aes(color="sub"))

ggplot(mapping=aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_step(data=data %>% count(date=week,name="articles") %>% right_join(weeks %>% distinct(week),by=c("date"="week")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,weeks(1)),aes(color="main")) +
geom_step(data=data2 %>% count(date=week,name="articles") %>% right_join(weeks %>% distinct(week),by=c("date"="week")) %>% replace_na(list(articles=0)) %>% duplicate_last(NA,date,weeks(1)),aes(color="sub"))

ggplot(mapping=aes(x=date,y=articles)) +
theme_hsci_discrete_gdocs() +
scale_y_continuous(limits=c(0,NA),breaks=seq(0,1000,by=c(10))) +
facet_wrap(~fct_relevel(media,"HS","STT","IL"),ncol=1) +
theme(legend.position = "none") +
ylab("Articles") +
scale_x_date(date_breaks = "2 months",date_labels = "%m/%y") +
geom_step(data=data %>% count(date=week,media,name="articles") %>% right_join(weeks,by=c("date"="week","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,weeks(1)),aes(color="main")) +
geom_step(data=data2 %>% count(date=week,media,name="articles") %>% right_join(weeks,by=c("date"="week","media")) %>% replace_na(list(articles=0)) %>% duplicate_last(media,date,weeks(1)),aes(color="sub"))
