I am giving only what you need for data manipulation, some calculations on labor economics indicator (growth, median, proportions) and graphical displays (like plotting barplots, time-series variables,etc.). There are many help online and feel free to ask me short questions by e-mails.

1- Import data set.

We are using a database I extract from Canadian Labor Force Survey collected by StatCan. The data is available on mycourses also in the folder “TA Conf.”. There are many options.

#Set directory of your workplace
setwd("C:/Users/MamadouYaya/Dropbox/Fall2019/TA_Fall2019/Data")
LFSCanada<- read.csv2("Can0718.txt", sep="")
names(LFSCanada)
##  [1] "rec_num"     "survyear"    "survmnth"    "prov"        "cma"        
##  [6] "age_12"      "age_3"       "sex"         "educ"        "marstatus"  
## [11] "immig"       "status"      "union_mem"   "indus"       "exper_month"
## [16] "class_work"  "uhrsmain"    "ahrsmain"    "ftptmain"    "hrlyearn"   
## [21] "permtemp"    "durunemp"    "finalwt"

2- Subsetting Data.

R is a free software and has powerful indexing features for accessing object elements.

Selecting or keeping variables

In R, you can access to specific variable in the database. There are many ways to select variables

In this case, select some variables and 5 first row. The only problem is not possible to target the name of the variables.

# % first row for some variables.
 Var_select1 <- LFSCanada[1:5,3:6]

It is possible to specifiy only the variables we want to select.

# Select "prov" , "cma" and "sex"  .

Var_select2 <- LFSCanada[c("prov","cma","sex")]

Selecting observations

You can also select subsequent observations.

# Displays first 5 observations.
obs_select1 <- LFSCanada[1:5,]

It is possible to select obervations given some specific criteria.

# Select individuals living in Ontario.
obs_select2 <- LFSCanada[which(LFSCanada$prov=='Ontario'), ]
# Select female living in Ontario.
obs_select3 <- LFSCanada[which(LFSCanada$prov=='Ontario' & LFSCanada$sex=='Female'), ]

We can use other function like subset to select obervations in an easy way.

# Select individuals living in Ontario.
obs_select4<- subset(LFSCanada, hrlyearn >= 15 | hrlyearn < 20, )

Usefull Links: Datacamp