I have a fairly easy piece of code to visualize a few parameteres about a country.
data_verylong %>%
filter(country %in% c("Germany")) %>%
ggplot(aes(year, value, color=indicator))+
geom_line()+
facet_wrap(vars(indicator), scales = "free_y", ncol = 1, strip.position = "top")+
theme(strip.background = element_blank(), strip.placement = "outside")
This is the result:
However, I want do make this dynamic as I want to dynamically get the data about different countries. And this is my code for this
deepdive <- function(country) {
data_verylong %>%
filter(country == country)%>%
ggplot(aes(year, value, color=indicator))+
geom_line()+
facet_wrap(vars(indicator), scales = "free_y", ncol = 1, strip.position = "top")+
theme(strip.background = element_blank(), strip.placement = "outside")
}
deepdive("Germany")
For some reason, the result looks very different and unusable. Has anyone encountered sth similar and can help me?