knitr::opts_chunk$set( error = FALSE, message = FALSE, warning = FALSE, collapse = TRUE, tidy = 'styler', fig.asp = 0.6, fig.width = 8, out.width = '100%', comment = "#>" )
library(tidyverse) library(lisr)
data <- get_lis_geo(rubrik_nr = 3) # weather
colnames(data)
data$KENNZIFFER
data.sub <- data %>% filter(str_detect(KENNZIFFER,"^Lufttemperatur") | str_detect(KENNZIFFER, "^Niederschlagsh")) %>% mutate(KENNZIFFER = case_when( str_detect(KENNZIFFER,"^Lufttemperatur") ~ "Temperature in °C (yearly mean)", str_detect(KENNZIFFER, "^Niederschlagsh") ~ "Rain in l (yearly sum)", TRUE ~ as.character(NA) ))
data.sub <- data.sub %>% pivot_longer( cols = matches("\\d{4}"), names_to = "Year", values_to = "Value" ) %>% mutate(Year = as.numeric(Year))
ggplot(data.sub, aes( x = Year, y = Value )) + geom_step() + geom_point(colour = "red3") + scale_x_continuous(breaks = seq(2000, 2024, 2)) + geom_smooth(method = "loess") + tidyquant::theme_tq() + theme(legend.position = "bottom") + facet_wrap(. ~ KENNZIFFER, nrow = 2, scales = "free") + labs( x = NULL, y = NULL, title = "Temperature and rain in Leipzig", subtitle = "2000 to 2023", caption = "Source: Leipzig Informationssystem, 2024" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.