This page is a supplement to the Introduction to Job Churn presentation given by Mervyn OLuing at the 4th Administrative Data Seminar, Dublin Castle, 20th April 2015
#These are the packages you need
#install.packages(c("googleVis","pxR","reshape"))
library("googleVis")
library("pxR")
library("reshape")
#Read in the following px file: JCA02 Job Churn Components by Nace Code, Year and Statistic, e.g. Jobs Created, Jobs Destroyed, etc.
#This is available from the CSO Statbank: http://www.cso.ie/px/pxeirestat/database/eirestat/Job%20Churn/Job%20Churn_statbank.asp?sp=Job%20Churn&Planguage=0
JCA02.px<- read.px("http://www.cso.ie/px/pxeirestat/Database/eirestat/Job%20Churn/JCA02.px")
#Convert this .px file into a data frame
JCA02df<-as.data.frame(JCA02.px)
#We need to reshape the data frame so as we can change the statistic categories into variables which have
#values for Year and Nace Code
JCA02 = dcast(JCA02df, Year + Activity.NACE.Rev.2 ~ Statistic, value.var="value", fun.aggregate=sum)
#We are going to prepare graphs for Nace Codes B to N,-642, so we can create a smaller dataset which just this category
ourdata<-subset(JCA02, Activity.NACE.Rev.2== "Business economy excluding activities of holding companies (B to N,-642)")
names(ourdata)[14]="Hirings"
names(ourdata)[15]="Separations"
names(ourdata)[16]="Job creation"
names(ourdata)[17]="Job destruction"
#line chart of Job Creation, Job Destruction, Hirings and Separations
churn<- gvisLineChart(ourdata, "Year", c("Job creation","Job destruction", "Hirings","Separations"),
options=list(
#set the size of the chart
height=800,width=1100,
#add a title and set the font type and size
title="Business economy excluding activities of holding companies (B to N,-642)",
titleTextStyle="{fontSize:16}",
#set the colour of the lines and include dashed lines for Hirings and Separations
series="[{color:'green', targetAxisIndex: 0},
{color:'red',targetAxisIndex:0},
{color:'#b9c246',targetAxisIndex:0, lineDashStyle: [4, 4]},{color:'#e7711b',targetAxisIndex:0, lineDashStyle: [4, 4] }]",
#set the line width/thickness
lineWidth=5,
gvis.editor="Edit me!"
))
plot(churn)