This scripts loads forestry datasets from EUROSTAT and displays data.
Original datasets and metadata can be viewed on the eurostat website. See also the Eurostat working group on forestry statistics and accounts.
There was a change in classification in 2008. Therefore EUROSTAT has 2 employment tables for the forest sector: “foremp_lfs1” Before 2008 and “for_emp_lfs” after 2008. We pull data from those 2 tables and mix them in some graph. Be aware that the employment figures before and after 2008 __are not comparable_. The difference by country for the year 2008 is computed in a table below.
library(SmarterPoland)
library(ggplot2)
library(xtable)
for_emp_lfs = getEurostatRCV(kod = "for_emp_lfs")
Description of the forestry employment datasets (for_emp_lfs1 before 2008 and for_emp_lfs after 2008) :
Sub-sectors of employment in forestry datasets:
# Change time to a numeric value
for_emp_lfs1$time = as.numeric(as.character(for_emp_lfs1$time))
for_emp_lfs$time = as.numeric(as.character(for_emp_lfs$time))
# Add a readable description of subsector of employment. Rename column and
# factor values. levels() keeps these columns as factor (The use of factors
# may not be needed).
for_emp_lfs1$subsector = for_emp_lfs1$nace_r1
levels(for_emp_lfs1$subsector)[levels(for_emp_lfs1$nace_r1) == "A0202"] = "Forestry and logging"
levels(for_emp_lfs1$subsector)[levels(for_emp_lfs1$nace_r1) == "DD20"] = "Manufacture of wood products except furniture"
levels(for_emp_lfs1$subsector)[levels(for_emp_lfs1$nace_r1) == "DE21"] = "Manufacture of paper products"
# Same manipulation for data after 2008
for_emp_lfs$subsector = for_emp_lfs$nace_r2
levels(for_emp_lfs$subsector)[levels(for_emp_lfs$nace_r2) == "A02"] = "Forestry and logging"
levels(for_emp_lfs$subsector)[levels(for_emp_lfs$nace_r2) == "C16"] = "Manufacture of wood products except furniture"
levels(for_emp_lfs$subsector)[levels(for_emp_lfs$nace_r2) == "C17"] = "Manufacture of paper products"
Before 2001, there is no aggregated EU data, however country level data is available (from 1992 onwards, see below).
Number of employees before 2008 with subsector classification nace_r1
EU28_r1 = subset(for_emp_lfs1, sex == "T" & isced97 == "TOTAL" & wstatus ==
"EMP" & geo == "EU28" & time > 2001)
p = ggplot() + geom_point(data = EU28_r1, aes(x = time, y = value, color = subsector)) +
ylab("Thousand employees")
# plot(p) # Uncomment to plot only before 2008
Number of employees after 2008 with subsector classification nace_r2
EU28 = subset(for_emp_lfs, sex == "T" & isced97 == "TOTAL" & wstatus == "EMP" &
geo == "EU28")
p + geom_point(data = EU28, aes(x = time, y = value, color = subsector))
Time series before 2008
emp1 = subset(for_emp_lfs1, sex == "T" & isced97 == "TOTAL" & wstatus == "EMP" &
!is.na(value) & !geo %in% c("EA13", "EA17", "EA18", "EU15", "EU27", "EU28"))
p = ggplot() + geom_line(data = emp1, aes(x = time, y = value, color = subsector)) +
ylab("Thousand employees") + scale_x_continuous(breaks = seq(1990, 2010,
10), limits = c(1990, 2013))
# plot(p + facet_wrap(~geo)) # Uncomment to plot only before 2008
Time series before and after 2008
# Select countries only
emp = subset(for_emp_lfs, sex == "T" & isced97 == "TOTAL" & wstatus == "EMP" &
!is.na(value) & !geo %in% c("EA13", "EA17", "EA18", "EU15", "EU27", "EU28"))
p = p + geom_line(data = emp, aes(x = time, y = value, color = subsector))
Plot employment by country with a fixed scale
plot(p + facet_wrap(~geo))
## geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
Plot employment by country with a free scale
plot(p + facet_wrap(~geo, scales = "free_y"))
## geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
emp1_8 = emp1[emp1$time == 2008, c("subsector", "geo", "value")]
emp$valueNewClassif = emp$value
emp_8 = emp[emp$time == 2008, c("subsector", "geo", "valueNewClassif")]
empComp = merge(emp1_8, emp_8)
empComp$diff = empComp$value - empComp$valueNewClassif
empComp = transform(empComp, diff = valueNewClassif - value, diffPercent = round((valueNewClassif -
value)/value * 100))
print(xtable(empComp), row.names = FALSE, type = "html")
| subsector | geo | value | valueNewClassif | diff | diffPercent | |
|---|---|---|---|---|---|---|
| 1 | Forestry and logging | AT | 10.80 | 12.10 | 1.30 | 12.00 |
| 2 | Forestry and logging | BE | 3.40 | 3.10 | -0.30 | -9.00 |
| 3 | Forestry and logging | CH | 8.20 | 7.20 | -1.00 | -12.00 |
| 4 | Forestry and logging | CY | 0.90 | 0.90 | 0.00 | 0.00 |
| 5 | Forestry and logging | CZ | 30.80 | 30.90 | 0.10 | 0.00 |
| 6 | Forestry and logging | DE | 42.90 | 44.20 | 1.30 | 3.00 |
| 7 | Forestry and logging | DK | 2.70 | 2.70 | 0.00 | 0.00 |
| 8 | Forestry and logging | EE | 7.20 | 7.10 | -0.10 | -1.00 |
| 9 | Forestry and logging | EL | 7.10 | 7.10 | 0.00 | 0.00 |
| 10 | Forestry and logging | ES | 31.80 | 31.60 | -0.20 | -1.00 |
| 11 | Forestry and logging | FI | 22.30 | 22.70 | 0.40 | 2.00 |
| 12 | Forestry and logging | FR | 51.40 | 48.00 | -3.40 | -7.00 |
| 13 | Forestry and logging | HR | 15.00 | 13.30 | -1.70 | -11.00 |
| 14 | Forestry and logging | HU | 12.20 | 12.80 | 0.60 | 5.00 |
| 15 | Forestry and logging | IE | 2.00 | 2.00 | 0.00 | 0.00 |
| 16 | Forestry and logging | IT | 43.10 | 42.20 | -0.90 | -2.00 |
| 17 | Forestry and logging | LT | 14.10 | 14.70 | 0.60 | 4.00 |
| 18 | Forestry and logging | LV | 16.60 | 16.60 | 0.00 | 0.00 |
| 19 | Forestry and logging | NL | 2.20 | 2.20 | 0.00 | 0.00 |
| 20 | Forestry and logging | NO | 4.30 | 4.30 | 0.00 | 0.00 |
| 21 | Forestry and logging | PT | 16.70 | 16.70 | 0.00 | 0.00 |
| 22 | Forestry and logging | RO | 50.00 | 49.10 | -0.90 | -2.00 |
| 23 | Forestry and logging | SK | 25.60 | 25.40 | -0.20 | -1.00 |
| 24 | Forestry and logging | UK | 21.00 | 21.00 | 0.00 | 0.00 |
| 25 | Manufacture of paper products | AT | 17.20 | 17.40 | 0.20 | 1.00 |
| 26 | Manufacture of paper products | BE | 14.90 | 15.10 | 0.20 | 1.00 |
| 27 | Manufacture of paper products | CH | 10.70 | 10.80 | 0.10 | 1.00 |
| 28 | Manufacture of paper products | CZ | 22.10 | 22.40 | 0.30 | 1.00 |
| 29 | Manufacture of paper products | DE | 144.30 | 143.50 | -0.80 | -1.00 |
| 30 | Manufacture of paper products | DK | 7.00 | 7.00 | 0.00 | 0.00 |
| 31 | Manufacture of paper products | EE | 2.40 | 1.80 | -0.60 | -25.00 |
| 32 | Manufacture of paper products | EL | 8.90 | 8.90 | 0.00 | 0.00 |
| 33 | Manufacture of paper products | ES | 44.00 | 44.00 | 0.00 | 0.00 |
| 34 | Manufacture of paper products | FI | 27.30 | 27.20 | -0.10 | -0.00 |
| 35 | Manufacture of paper products | FR | 84.70 | 84.70 | 0.00 | 0.00 |
| 36 | Manufacture of paper products | HR | 5.20 | 5.40 | 0.20 | 4.00 |
| 37 | Manufacture of paper products | HU | 14.50 | 14.50 | 0.00 | 0.00 |
| 38 | Manufacture of paper products | IT | 94.90 | 96.20 | 1.30 | 1.00 |
| 39 | Manufacture of paper products | LV | 1.90 | 2.00 | 0.10 | 5.00 |
| 40 | Manufacture of paper products | NL | 22.20 | 22.20 | 0.00 | 0.00 |
| 41 | Manufacture of paper products | NO | 4.90 | 4.90 | 0.00 | 0.00 |
| 42 | Manufacture of paper products | PT | 15.60 | 15.60 | 0.00 | 0.00 |
| 43 | Manufacture of paper products | RO | 15.90 | 17.30 | 1.40 | 9.00 |
| 44 | Manufacture of paper products | SK | 9.60 | 9.90 | 0.30 | 3.00 |
| 45 | Manufacture of paper products | UK | 71.40 | 71.40 | 0.00 | 0.00 |
| 46 | Manufacture of wood products except furniture | AT | 49.70 | 34.20 | -15.50 | -31.00 |
| 47 | Manufacture of wood products except furniture | BE | 23.50 | 23.60 | 0.10 | 0.00 |
| 48 | Manufacture of wood products except furniture | CH | 38.90 | 40.00 | 1.10 | 3.00 |
| 49 | Manufacture of wood products except furniture | CY | 3.50 | 3.50 | 0.00 | 0.00 |
| 50 | Manufacture of wood products except furniture | CZ | 65.70 | 46.10 | -19.60 | -30.00 |
| 51 | Manufacture of wood products except furniture | DE | 143.70 | 131.40 | -12.30 | -9.00 |
| 52 | Manufacture of wood products except furniture | DK | 13.70 | 13.50 | -0.20 | -1.00 |
| 53 | Manufacture of wood products except furniture | EE | 15.60 | 15.20 | -0.40 | -3.00 |
| 54 | Manufacture of wood products except furniture | EL | 27.10 | 27.00 | -0.10 | -0.00 |
| 55 | Manufacture of wood products except furniture | ES | 106.40 | 104.60 | -1.80 | -2.00 |
| 56 | Manufacture of wood products except furniture | FI | 30.50 | 30.80 | 0.30 | 1.00 |
| 57 | Manufacture of wood products except furniture | FR | 106.70 | 96.30 | -10.40 | -10.00 |
| 58 | Manufacture of wood products except furniture | HR | 20.60 | 20.60 | 0.00 | 0.00 |
| 59 | Manufacture of wood products except furniture | HU | 34.40 | 31.80 | -2.60 | -8.00 |
| 60 | Manufacture of wood products except furniture | IE | 7.50 | 8.70 | 1.20 | 16.00 |
| 61 | Manufacture of wood products except furniture | IT | 169.10 | 166.20 | -2.90 | -2.00 |
| 62 | Manufacture of wood products except furniture | LT | 27.40 | 27.60 | 0.20 | 1.00 |
| 63 | Manufacture of wood products except furniture | LV | 28.70 | 28.70 | 0.00 | 0.00 |
| 64 | Manufacture of wood products except furniture | NL | 25.30 | 25.30 | 0.00 | 0.00 |
| 65 | Manufacture of wood products except furniture | NO | 16.80 | 16.80 | 0.00 | 0.00 |
| 66 | Manufacture of wood products except furniture | PT | 57.20 | 56.80 | -0.40 | -1.00 |
| 67 | Manufacture of wood products except furniture | RO | 108.90 | 107.60 | -1.30 | -1.00 |
| 68 | Manufacture of wood products except furniture | SK | 29.00 | 28.10 | -0.90 | -3.00 |
| 69 | Manufacture of wood products except furniture | UK | 80.40 | 80.40 | 0.00 | 0.00 |
library(maptools)
library(ggplot2)
library(ggmap)
gpclibPermit() # Test if the General Polygon Clipping Library for R is there
# gpclib is needed otherwise fortify() returns the Error:
# isTRUE(gpclibPermitStatus()) is not TRUE
# read administrative boundaries (change folder appropriately) Data from
# http://epp.eurostat.ec.europa.eu/portal/page/portal/gisco_Geographical_information_maps/popups/references/administrative_units_statistical_units_1
eurMap = readShapePoly(fn = "rawdata/NUTS_2010_60M_SH/data/NUTS_RG_60M_2010")
# plot(eurMap) # Would draw the map of Europe at the NUTS-3 level.
# Transform eurMap to a data frame for use with ggplot2
eurMapDf = fortify(eurMap, region = "NUTS_ID")
# Read downloaded data (change folder appropriately)
eurEdu <- read.csv("rawdata/educ_thexp_1_Data.csv", stringsAsFactors = F)
eurEdu$Value <- as.double(eurEdu$Value) #format as numeric
################################# Merge map and Employment data # limit data to main Europe
europe.limits <- geocode(c("Cape Fligely, Rudolf Island, Franz Josef Land, Russia",
"Gavdos, Greece", "Faja Grande, Azores", "Severny Island, Novaya Zemlya, Russia"))
eurMapDf <- subset(eurMapDf, long > min(europe.limits$lon) & long < max(europe.limits$lon) &
lat > min(europe.limits$lat) & lat < max(europe.limits$lat))
# Merge map and data
emp2012 = subset(for_emp_lfs, sex == "T" & isced97 == "TOTAL" & wstatus == "EMP" &
!is.na(value) & !geo %in% c("EA13", "EA17", "EA18", "EU15", "EU27", "EU28") &
time == 2012 & nace_r2 == "A02")
eurEmpMapDf = merge(eurMapDf, emp2012, by.x = "id", by.y = "geo")
# limit data to main Europe
eurEmpMapDf <- subset(eurEmpMapDf, long > min(europe.limits$lon) & long < max(europe.limits$lon) &
lat > min(europe.limits$lat) & lat < max(europe.limits$lat))
# Mapping
m0 <- ggplot(data = eurEmpMapDf)
m1 <- m0 + geom_polygon(aes(x = long, y = lat, group = group, fill = value)) +
coord_equal()
m2 <- m1 + geom_path(aes(x = long, y = lat, group = group), color = "black")
m2