Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
Last active August 14, 2018 16:41
Show Gist options
  • Save mschnetzer/e70ad23bffef54bcd0b80fcc0e69170e to your computer and use it in GitHub Desktop.
Save mschnetzer/e70ad23bffef54bcd0b80fcc0e69170e to your computer and use it in GitHub Desktop.
Zufriedenheit mit Gesundheitsversorgung in % (https://twitter.com/matschnetzer/status/975748716027174912)
library(eurostat)
library(tidyverse)
library(RColorBrewer)
library(ggthemes)
# Vector with capital cities only
caps <- c(paste0(c("AT","BE","BG","CY","CZ","DE","DK","EE","EK","EL","ES","FI","FR","HR","HU","IE","IS",
"IT","LT","LU","LV","MT","NO","PL","PT","RO","SE","SI","SK","TR"), '001C1'),"NL002C1","FI001C2","UK001K2")
# Load data from Eurostat Perception Survey
# Zufriedenheit mit der Gesundheitsversorgung (durch Ärzte und Krankenhäuser)
data <- get_eurostat("urb_percep",filters=list(cities=caps,indic_ur=c("PS3042V","PS3043V"),lastTimePeriod=1),type="label",time_format = "num") %>%
mutate(cities=recode(cities, "London (greater city)" = "London", "Bruxelles / Brussel" = "Bruxelles", "Helsinki / Helsingfors" = "Helsinki"))
levels(data$indic_ur) <- c("very","rather")
health <- data %>% select(indic_ur,cities,values) %>% spread(indic_ur,values) %>%
mutate(satisfied = very+rather) %>% arrange(satisfied) %>% mutate(row = row_number()) %>% na.omit()
health %>% select(row,cities,satisfied) %>%
ggplot(aes(row)) +
geom_bar(aes(y=satisfied),stat = "identity",fill="brown2") +
geom_text(aes(label=satisfied,y=2,fontface = "bold"),color="white") +
coord_flip() + theme_wsj() + scale_y_continuous(limits = c(0,100)) +
scale_x_continuous(
breaks = health$row,
labels = health$cities,
expand = c(0,0)
) + ggsave(filename="healthsat.pdf",scale=2,width=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment