Using SmarterPoland-package in accessing Eurostat data

06 Aug 2013

SmarterPoland-package provides a straghtforward connection to Eurostat data. It is uninformatively described as:

A set of tools developed by the Foundation SmarterPoland.pl Tools for accessing and processing datasets presented on the blog SmarterPoland.pl.

But in real terms it has functionality only towards Eurostat. Here is a brief demo how you can search for material deprivation and then create a line plot at NUTS2 level.

library(SmarterPoland)
searchresults <- grepEurostatTOC("material deprivation")
df <- getEurostatRCV(kod = "ilc_mddd21")

Plot at nuts2-level

# time variable into numerical
df$time <- as.numeric(levels(df$time))[df$time]
cname <- subset(df, time == 2011)

# plot
library(ggplot2)
ggplot(df, aes(x=time,y=value, color=geo,group=geo)) + 
  geom_point() + geom_line() +
  geom_text(data=cname, 
            aes(x=time,y=value,label=geo), hjust=-0.3) +
  theme(legend.position="none") +
  labs(title="material deprivation in EU at NUTS2-level",
       y="population share (%)") +
  coord_cartesian(xlim=c(2003,2012)) +
  scale_x_continuous(breaks = 2003:2011)

Plot at nuts1-level

# subset geo-names only lenght of 2 characters
df$geo <- as.character(df$geo)
df$geo.n <- nchar(df$geo)
df <- subset(df, geo.n < 3)

cname <- subset(df, time == 2011)

# plot
library(ggplot2)
ggplot(df, aes(x=time,y=value, color=geo,group=geo)) + 
  geom_point() + geom_line() +
  geom_text(data=cname, 
            aes(x=time,y=value,label=geo), hjust=-0.3) +
  theme(legend.position="none") +
  labs(title="material deprivation in EU at NUTS2-level",
       y="population share (%)") +
  coord_cartesian(xlim=c(2003,2012)) +
  scale_x_continuous(breaks = 2003:2011)
comments powered by Disqus