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(lisr) library(tidyverse)
data <- get_lis_housing(rubrik_nr = 3) # flat rents
colnames(data)
data$KENNZIFFER
data <- data %>% mutate(MIETE = c(rep('Grundmiete', 5), rep('Gesamtmiete', 5))) %>% relocate(MIETE)
data.sub <- data %>% filter(KENNZIFFER == "Haushalte insgesamt")
data.sub <- data.sub %>% pivot_longer( cols = matches("\\d{4}"), names_to = "Year", values_to = "Rent" ) %>% mutate(Year = as.numeric(str_remove(Year, "JAHR_")))
ggplot(data.sub, aes( x = Year, y = Rent, colour = MIETE, group = MIETE )) + geom_line() + geom_point() + scale_x_continuous(breaks = seq(2000, 2024, 2)) + scale_y_continuous(breaks = seq(4, 9, 1)) + hrbrthemes::theme_modern_rc() + theme(legend.position = "bottom") + labs( colour = NULL, y = "€ / m²", title = "Median rent in Leipzig", subtitle = "2000 to 2022", caption = "Source: Leipzig Informationssystem, 2024" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.