Skip to content

Instantly share code, notes, and snippets.

@jamestrimble
Created September 16, 2013 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamestrimble/6578789 to your computer and use it in GitHub Desktop.
Save jamestrimble/6578789 to your computer and use it in GitHub Desktop.
# eurostat_r.r should be in the working directory.
# See http://johanneskutsam.blogspot.co.uk/2012/10/eurostat-in-r-in-git.html
library(ggplot2)
library(scales)
source('eurostat_r.r')
 
eu_codes <- c('BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'EL', 'ES',
              'FR', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT',
              'NL', 'AT', 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE',
              'UK')
 
u <- read.eurostat('une_rt_q')
# Youth unemployment since 2000
youth_unemployment <- subset(u, time >= as.yearqtr('2000 Q1'&
S_ADJ=='SA' &
AGE=='Y_LT25' &
GEO %in% eu_codes)
youth_unemployment$time <- as.Date(youth_unemployment$time)
# Shorten name for Germany
levels(youth_unemployment$GEO_desc)[levels(youth_unemployment$GEO_desc)==
'Germany (until 1990 former territory of the FRG)'] <-
'Germany'
png('youth_unemployment.png', width=900, height=600)
ggplot(youth_unemployment, aes(x=time, y=value, colour=SEX_desc, group=SEX_desc)) +
  facet_wrap(~ GEO_desc) +
  geom_line() +
theme_bw() +
  xlab('Year') +
  ylab('Youth unemployment rate') +
scale_x_date(labels = date_format("%y")) +
theme(legend.title=element_blank())
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment