Importing employment data into R
Our first step in this project is to import the employment data into R so that we can start assessing the data and perform some preliminary analysis.
Getting ready
You should be ready to go ahead after completing the previous recipe.
How to do it...
The following steps will guide you through two different ways of importing the CSV file:
- We can directly load the data file into R (even from the compressed version) using the following command:
ann2012 <- read.csv(unz('2012_annual_singlefile.zip',
'2012.annual.singlefile.csv'), stringsAsFactors=F)
However, you will find that this takes a very long time with this file. There are better ways.
- We chose to import the data directly into R since there are further manipulations and merges that we will do later. We will use the
fread
function from thedata.table
package to do this:
library(data.table) ann2012 <- fread('data/2012.annual.singlefile.csv')
That's it. Really! It is also many times faster than the other...