knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Use the iffi-data to find out in which week the most events happened
We use the data that already comes with the iffitoR
-package
first we load the packages
library(iffitoR) library(lubridate) library(stringr) library(leaflet.extras) library(sf) library(leaflet) library(dplyr) library(ggplot2) library(glue) library(forcats)
data_iffi = landsld glimpse(data_iffi)
data_iffi %>% filter(str_detect(second_level, "translational")) %>% count(date, sort=T)
dat = data_iffi %>% filter(date == as.Date("2020-12-06")) %>% st_transform(4326) # the color palette for the categorical data cf = colorFactor(palette = "RdYlBu", domain=dat$second_level) sl = unique(dat$second_level) map = leaflet(dat) %>% addProviderTiles(providers$Stamen.TonerLite) for (g in sl) { d = dat %>% filter(second_level == g) map = map %>% addCircles( data = d, popup = paste0("date: ", d$date, "<br>", "type:", d$second_level), color = ~ cf(d$second_level), group = g ) } map %>% addLayersControl(overlayGroups = sl)
library(showtext) library(extrafont) loadfonts() data_iffi %>% filter(date_info == "day") %>% filter(str_detect(second_level, "translational")) %>% mutate(week = paste0(year.int, formatC(week(date), flag=0, width=2))) %>% count(week, sort=T) %>% mutate(first_day_of_week = as.Date(paste0(week, 1), "%Y%U%u")) %>% mutate(week = glue("{first_day_of_week} ({n})")) %>% mutate(week = fct_reorder(week, n)) %>% head(n = 12) %>% ggplot() + geom_col(aes(x=n, y=week), color="black") + theme_light(base_family="Times New Roman") + labs(x = "# of events per week", y = "Week", title = "Weeks with highest number of Slides") + theme( axis.title.y = element_blank() )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.