Basics of R

Olesya Volchenko, Anna Shirokanova

January 20, 2020

What’s going on?

Stages of R

Structure of R

Installing R

Installing Rstudio

Where To Start

Creating an Object

Assignment

x <- 5
x
## [1] 5
x <- x + 5

Functions

In R Function takes a form of: function.name(x,y,z)
where x, y and z - arguments of our function.
For example, function sum()

sum(x = 10, y = 15)
## [1] 25
x1 <- sum(x = 10, y = 15)

R as a calculator

2 + 2
## [1] 4
2 * 3
## [1] 6
2^3
## [1] 8
(100-25)/3
## [1] 25

R as a calculator

exp(1)
## [1] 2.718282
log(10)
## [1] 2.302585
sqrt(2)
## [1] 1.414214
prod(2,3)
## [1] 6
abs(-10)
## [1] 10

Data types in R

Vector

a <- c(1, 2, 3); a
## [1] 1 2 3
b <- rep(1, 10); b
##  [1] 1 1 1 1 1 1 1 1 1 1
c <- seq(1, 5, 1); c
## [1] 1 2 3 4 5
d <- 1:5; d
## [1] 1 2 3 4 5

Data classes

x <- c(1, 5, 9.5)
y <- c("good", "satisf", "bad")
l <- c(T, F, F)
class(x)
## [1] "numeric"
class(y)
## [1] "character"
class(l)
## [1] "logical"

Factors

f <- factor(c("yes","no","yes","maybe","maybe","no","maybe","no","no"))
f
## [1] yes   no    yes   maybe maybe no    maybe no    no   
## Levels: maybe no yes

Data frame

name <- c("Masha", "Vasya", "Anya", "Petya", "Vanya")
age <- c(18, 17, 19, 21, 20)
weight <- c(45, 80, 69, 92, 60)
height <- c(1.62, 1.75, 1.82, 1.92, 1.70)
gender <- c("F", "M", "F", "M", "M")
course <- c(1, 1, 2, 3, 4)
students <- data.frame(name, age, weight, height, gender, course)
students
##    name age weight height gender course
## 1 Masha  18     45   1.62      F      1
## 2 Vasya  17     80   1.75      M      1
## 3  Anya  19     69   1.82      F      2
## 4 Petya  21     92   1.92      M      3
## 5 Vanya  20     60   1.70      M      4

Taking a look at a part of an object

Let’s call for “gender” variable from “students” dataset

students$gender
## [1] F M F M M
## Levels: F M
students[1,1] #the 1st row of the 1st column
## [1] Masha
## Levels: Anya Masha Petya Vanya Vasya
students[1, ] #the 1st row 
##    name age weight height gender course
## 1 Masha  18     45   1.62      F      1
students[ , 1] #the 1st column
## [1] Masha Vasya Anya  Petya Vanya
## Levels: Anya Masha Petya Vanya Vasya

head() - the first 6 rows of your dataset

tail() - the last 6 rows of your dataset

Working directory, environment

wd - a folder on your computer where R locates files

getwd() # take a look at existing/default wd
## [1] "C:/Users/lssi5/YandexDisk/teaching/DA BA 2019"
#setwd() # set a new wd
#dir()

Avoid cyrillic characters in your working directory

I want to work with real data!

A real life example!

Let’s upload the data set into R environment

First, we need to check whether the file is in our working directory using dir()

library(foreign)
ESS <- read.spss("C:/Users/lssi5/YandexDisk/teaching/data/ESS5e03_4.sav", use.value.labels=T, to.data.frame=T)
dim(ESS)
## [1] 52458   674
head(ESS)
##           name essround edition   proddate   idno   cntry
## 1 ESS5e03_4           5     3.4 01.12.2018 100102 Belgium
## 2 ESS5e03_4           5     3.4 01.12.2018 100106 Belgium
## 3 ESS5e03_4           5     3.4 01.12.2018 100202 Belgium
## 4 ESS5e03_4           5     3.4 01.12.2018 100204 Belgium
## 5 ESS5e03_4           5     3.4 01.12.2018 100209 Belgium
## 6 ESS5e03_4           5     3.4 01.12.2018 100301 Belgium
##                                tvtot                             tvpol
## 1 More than 2 hours, up to 2,5 hours                Less than 0,5 hour
## 2 More than 1,5 hours, up to 2 hours More than 1 hour, up to 1,5 hours
## 3 More than 1,5 hours, up to 2 hours                    No time at all
## 4                 0,5 hour to 1 hour                0,5 hour to 1 hour
## 5                  More than 3 hours More than 1 hour, up to 1,5 hours
## 6 More than 2 hours, up to 2,5 hours                    No time at all
##                rdtot                              rdpol            nwsptot
## 1 Less than 0,5 hour                     No time at all Less than 0,5 hour
## 2 0,5 hour to 1 hour                 0,5 hour to 1 hour Less than 0,5 hour
## 3     No time at all                               <NA>     No time at all
## 4  More than 3 hours                 0,5 hour to 1 hour     No time at all
## 5  More than 3 hours More than 1,5 hours, up to 2 hours     No time at all
## 6     No time at all                               <NA> Less than 0,5 hour
##              nwsppol                    netuse                  ppltrst
## 1 Less than 0,5 hour    Less than once a month                        8
## 2 0,5 hour to 1 hour      Several times a week You can't be too careful
## 3               <NA>                 Every day                        5
## 4               <NA>                 Every day                        6
## 5               <NA> No access at home or work                        6
## 6 Less than 0,5 hour                 Every day                        4
##                                   pplfair pplhlp               polintr
## 1                                       7      7 Not at all interested
## 2 Most people try to take advantage of me      2       Very interested
## 3                                       5      5 Not at all interested
## 4                                       6      7      Quite interested
## 5                                       8      5      Quite interested
## 6                                       4      5      Quite interested
##   trstprl        trstlgl        trstplc trstplt trstprt         trstep
## 1       4              6              7       3       3              6
## 2       5              4              4       5       4              3
## 3       5 Complete trust Complete trust       5       5 Complete trust
## 4       3              3              5       5       4              7
## 5       4              5              8       4       4              4
## 6       3              1              4       2       2              3
##   trstun vote prtvtcbe prtvtbbg prtvtcch prtvthr prtvtcy prtvtbcz prtvcde1
## 1      7  Yes   Groen!     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
## 2      2   No     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
## 3      5  Yes     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
## 4      8  Yes Open VLD     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
## 5      8  Yes     SP.A     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
## 6      3  Yes     N-VA     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>
##   prtvcde2 prtvtbdk prtvtcee prtvtbes prtvtbfi prtvtbfr prtvtgb prtvtcgr
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>
##   prtvtchu prtvtaie prtvtbil prtvlt1 prtvlt2 prtvlt3 prtvtdnl prtvtano
## 1     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>     <NA>     <NA>
##   prtvtbpl prtvtbpt prtvtbru prtvtase prtvtcsi prtvtbsk prtvtbua contplt
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>      No
##   wrkprty wrkorg badge sgnptit pbldmn bctprd clsprty prtclcbe prtclbbg
## 1      No    Yes    No      No     No     No     Yes   Groen!     <NA>
## 2      No     No    No      No     No    Yes     Yes     SP.A     <NA>
## 3      No     No    No     Yes     No     No     Yes Open VLD     <NA>
## 4      No     No    No      No     No     No      No     <NA>     <NA>
## 5      No     No    No      No     No     No     Yes     SP.A     <NA>
## 6      No     No    No      No     No     No      No     <NA>     <NA>
##   prtclcch prtclcy prtclhr prtclbcz prtclcde prtclbdk prtclcee prtclbes
## 1     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 2     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 4     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 6     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
##   prtclbfi prtclcfr prtclgb prtclcgr prtclchu prtclcie prtclbil prtcllt
## 1     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 2     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 3     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 4     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 5     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 6     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
##   prtclcnl prtclano prtcldpl prtclcpt prtclbru prtclase prtclcsi prtclbsk
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
##   prtclcua     prtdgcl mmbprty prtmbcbe prtmbbbg prtmbcch prtmbhr prtmbcy
## 1     <NA> Quite close      No     <NA>     <NA>     <NA>    <NA>    <NA>
## 2     <NA> Quite close      No     <NA>     <NA>     <NA>    <NA>    <NA>
## 3     <NA>   Not close      No     <NA>     <NA>     <NA>    <NA>    <NA>
## 4     <NA>        <NA>      No     <NA>     <NA>     <NA>    <NA>    <NA>
## 5     <NA> Quite close      No     <NA>     <NA>     <NA>    <NA>    <NA>
## 6     <NA>        <NA>      No     <NA>     <NA>     <NA>    <NA>    <NA>
##   prtmbbcz prtmbcde prtmbbdk prtmbcee prtmbbes prtmbbfi prtmbcfr prtmbgb
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
##   prtmbcgr prtmbchu prtmbbie prtmbbil prtmblt prtmbcnl prtmbano prtmbdpl
## 1     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>
##   prtmbbpt prtmbbru prtmbase prtmbcsi prtmbbsk prtmbcua lrscale stflife
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       1       7
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       5       5
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       5       8
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       4       8
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       2       9
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>       5       3
##                stfeco                 stfgov stfdem stfedu stfhlth
## 1                   7 Extremely dissatisfied      7      7       8
## 2                   4                      3      3      3       1
## 3 Extremely satisfied                      5      5      8       8
## 4                   1                      1      5      6       7
## 5                   7                      5      6      8       7
## 6                   2                      2      2      8       8
##          gincdif                    freehms                    prtyban
## 1          Agree          Disagree strongly Neither agree nor disagree
## 2 Agree strongly Neither agree nor disagree                      Agree
## 3          Agree                      Agree                      Agree
## 4 Agree strongly             Agree strongly             Agree strongly
## 5 Agree strongly             Agree strongly                      Agree
## 6 Agree strongly             Agree strongly             Agree strongly
##                      scnsenv                          imsmetn
## 1                      Agree                       Allow some
## 2 Neither agree nor disagree Allow many to come and live here
## 3 Neither agree nor disagree                      Allow a few
## 4                      Agree Allow many to come and live here
## 5                      Agree                      Allow a few
## 6 Neither agree nor disagree                      Allow a few
##                            imdfetn     impcntr imbgeco imueclt imwbcnt
## 1                       Allow some  Allow some       7       6       6
## 2 Allow many to come and live here Allow a few       4       5       5
## 3                      Allow a few Allow a few       5       8       2
## 4 Allow many to come and live here  Allow some       6       7       7
## 5                      Allow a few Allow a few       6       8       8
## 6                      Allow a few Allow a few       2       8       5
##   happy              sclmeet inmdisc              sclact crmvct
## 1     8          Once a week     Yes      About the same     No
## 2     8          Once a week      No Much less than most    Yes
## 3     8          Once a week     Yes      Less than most     No
## 4     8 Several times a week     Yes      About the same     No
## 5     9 Several times a week     Yes      About the same     No
## 6     2          Once a week      No      Less than most     No
##       aesfdrk           brghmwr                           brghmef
## 1   Very safe             Never                              <NA>
## 2        Safe             Never                              <NA>
## 3 Very unsafe Just occasionally No real effect on quality of life
## 4        Safe             Never                              <NA>
## 5        Safe  Some of the time                       Some effect
## 6        Safe  Some of the time                       Some effect
##             crvctwr                           crvctef health hlthhmp
## 1             Never                              <NA>   Good      No
## 2  Some of the time No real effect on quality of life   Fair      No
## 3  Some of the time                       Some effect   Good      No
## 4             Never                              <NA>   Good      No
## 5             Never                              <NA>   Good      No
## 6 Just occasionally No real effect on quality of life   Good      No
##   rlgblg         rlgdnm           rlgdnbe rlgdnach rlgdncy rlgdnde rlgdndk
## 1    Yes        Islamic      Islam/Moslim     <NA>    <NA>    <NA>    <NA>
## 2     No           <NA>              <NA>     <NA>    <NA>    <NA>    <NA>
## 3     No           <NA>              <NA>     <NA>    <NA>    <NA>    <NA>
## 4    Yes Roman Catholic (Rooms) Katholiek     <NA>    <NA>    <NA>    <NA>
## 5     No           <NA>              <NA>     <NA>    <NA>    <NA>    <NA>
## 6    Yes Roman Catholic (Rooms) Katholiek     <NA>    <NA>    <NA>    <NA>
##   rlgdnafi rlgdngb rlgdnagr rlgdnhu rlgdnie rlgdnil rlgdnlt rlgdnnl
## 1     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 3     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 4     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 5     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 6     <NA>    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##   rlgdnno rlgdnapl rlgdnpt rlgdnaru rlgdnase rlgdnsi rlgdnsk rlgdnua
## 1    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 2    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 3    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 4    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 5    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 6    <NA>     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
##   rlgblge rlgdnme rlgdebe rlgdeach rlgdecy rlgdede rlgdedk rlgdeafi
## 1    <NA>    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
## 2      No    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
## 3      No    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
## 4    <NA>    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
## 5      No    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
## 6    <NA>    <NA>    <NA>     <NA>    <NA>    <NA>    <NA>     <NA>
##   rlgdegb rlgdeagr rlgdehu rlgdeie rlgdeil rlgdelt rlgdenl rlgdeno
## 1    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 3    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 4    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 5    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 6    <NA>     <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##   rlgdeapl rlgdept rlgdearu rlgdease rlgdesi rlgdesk rlgdeua
## 1     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 2     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 3     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 4     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 5     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 6     <NA>    <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
##                 rlgdgr     rlgatnd       pray dscrgrp    dscrrce
## 1                    5       Never      Never      No Not marked
## 2                    7  Less often  Every day      No Not marked
## 3 Not at all religious       Never      Never      No Not marked
## 4                    5  Less often      Never      No Not marked
## 5                    5       Never Less often     Yes Not marked
## 6                    9 Once a week  Every day      No Not marked
##      dscrntn    dscrrlg    dscrlng    dscretn    dscrage    dscrgnd
## 1 Not marked Not marked Not marked Not marked Not marked Not marked
## 2 Not marked Not marked Not marked Not marked Not marked Not marked
## 3 Not marked Not marked Not marked Not marked Not marked Not marked
## 4 Not marked Not marked Not marked Not marked Not marked Not marked
## 5 Not marked Not marked Not marked Not marked Not marked Not marked
## 6 Not marked Not marked Not marked Not marked Not marked Not marked
##      dscrsex    dscrdsb    dscroth     dscrdk    dscrref    dscrnap
## 1 Not marked Not marked Not marked Not marked Not marked     Marked
## 2 Not marked Not marked Not marked Not marked Not marked     Marked
## 3 Not marked Not marked Not marked Not marked Not marked     Marked
## 4 Not marked Not marked Not marked Not marked Not marked     Marked
## 5 Not marked Not marked     Marked Not marked Not marked Not marked
## 6 Not marked Not marked Not marked Not marked Not marked     Marked
##       dscrna ctzcntr                              ctzshipb brncntr
## 1 Not marked     Yes                                  <NA>      No
## 2 Not marked      No Congo, The Democratic Republic of the      No
## 3 Not marked     Yes                                  <NA>     Yes
## 4 Not marked     Yes                                  <NA>     Yes
## 5 Not marked     Yes                                  <NA>     Yes
## 6 Not marked     Yes                                  <NA>     Yes
##                                cntbrthb livecnta lnghom1 lnghom2 blgetmg
## 1                                Turkey     1992 Kurdish   Dutch      No
## 2 Congo, The Democratic Republic of the     2008  French    <NA>      No
## 3                                  <NA>     <NA>   Dutch    <NA>      No
## 4                                  <NA>     <NA>  French   Dutch      No
## 5                                  <NA>     <NA>   Dutch    <NA>      No
## 6                                  <NA>     <NA>   Dutch    <NA>      No
##   facntr                              fbrncnta mocntr
## 1     No                                Turkey     No
## 2     No Congo, The Democratic Republic of the     No
## 3    Yes                                  <NA>    Yes
## 4    Yes                                  <NA>     No
## 5    Yes                                  <NA>    Yes
## 6    Yes                                  <NA>    Yes
##                                mbrncnta         insclwr         bystlwr
## 1                                Turkey           Wrong           Wrong
## 2 Congo, The Democratic Republic of the     A bit wrong Seriously wrong
## 3                                  <NA>     A bit wrong     A bit wrong
## 4 Congo, The Democratic Republic of the Seriously wrong Seriously wrong
## 5                                  <NA> Seriously wrong           Wrong
## 6                                  <NA> Seriously wrong Seriously wrong
##            trfowr         insclct           bystlct          trfoct
## 1 Seriously wrong Not very likely            Likely     Very likely
## 2           Wrong     Very likely       Very likely     Very likely
## 3 Seriously wrong          Likely   Not very likely     Very likely
## 4           Wrong     Very likely   Not very likely     Very likely
## 5 Seriously wrong Not very likely Not at all likely Not very likely
## 6 Seriously wrong     Very likely       Very likely          Likely
##                    plcjbcn plccont                             plcstf
## 1                 Good job     Yes Neither dissatisfied nor satisfied
## 2 Neither good nor bad job      No                               <NA>
## 3                 Good job     Yes                     Very satisfied
## 4                  Bad job     Yes Neither dissatisfied nor satisfied
## 5                 Good job     Yes                  Very dissatisfied
## 6                 Good job     Yes                     Very satisfied
##                         plcvcrp                                  plcvcrc
## 1     Poor people treated worse People from different race treated worse
## 2     Poor people treated worse    People from all races treated equally
## 3 Rich and poor treated equally People from different race treated worse
## 4     Poor people treated worse People from different race treated worse
## 5 Rich and poor treated equally People from different race treated worse
## 6     Poor people treated worse People from different race treated worse
##   plcpvcr plccbrg          plcarcr        plcrspc        plcfrdc
## 1      05      05 Extremely slowly Not very often Not very often
## 2      05      05                5 Not very often Not very often
## 3      05      03                4          Often Not very often
## 4      04      05                7 Not very often          Often
## 5      08      06                7          Often Not very often
## 6      04      02                3          Often Not very often
##                                  plcexdc             bplcdc
## 1                         Not very often Not at all my duty
## 2                         Not very often                  5
## 3                                  Often Completely my duty
## 4 No one ever asks the police to explain                  4
## 5                                  Often                  2
## 6                         Not very often                  8
##              doplcsy            dpcstrb                    plcrgwr
## 1 Not at all my duty Not at all my duty                      Agree
## 2                  5                  5 Neither agree nor disagree
## 3 Completely my duty Completely my duty                      Agree
## 4                  4                  5                      Agree
## 5                  2                  2 Neither agree nor disagree
## 6                  8                  8                      Agree
##                      plcipvl                    gsupplc
## 1 Neither agree nor disagree Neither agree nor disagree
## 2 Neither agree nor disagree Neither agree nor disagree
## 3                      Agree             Agree strongly
## 4                   Disagree Neither agree nor disagree
## 5                      Agree                      Agree
## 6                      Agree                      Agree
##                      plciplt plccbrb                  ctjbcnt ctmtgfr
## 1                      Agree       1                 Good job       7
## 2             Agree strongly       5 Neither good nor bad job       5
## 3 Neither agree nor disagree       8                 Good job       5
## 4 Neither agree nor disagree       6                 Good job       6
## 5                      Agree       8                 Good job       8
## 6             Agree strongly       5 Neither good nor bad job       7
##   ctfrdc                                    wraccrp
## 1      3 Poor person more likely to be found guilty
## 2      5 Poor person more likely to be found guilty
## 3      8 Poor person more likely to be found guilty
## 4      5 Poor person more likely to be found guilty
## 5      8 Poor person more likely to be found guilty
## 6      3 Poor person more likely to be found guilty
##                                                     wraccrc jdgcbrb
## 1               All races same chance of being found guilty       1
## 2               All races same chance of being found guilty       5
## 3 Person from different race more likely to be found guilty       7
## 4      Person from same race more likely to be found guilty       3
## 5      Person from same race more likely to be found guilty       8
## 6 Person from different race more likely to be found guilty       7
##                      ctprpwr       hrshsnta                    dbctvrd
## 1                      Agree          Agree Neither agree nor disagree
## 2             Agree strongly Agree strongly Neither agree nor disagree
## 3 Neither agree nor disagree Agree strongly                   Disagree
## 4 Neither agree nor disagree       Disagree                   Disagree
## 5             Agree strongly          Agree                   Disagree
## 6             Agree strongly Agree strongly Neither agree nor disagree
##                      lwstrob                    rgbrklw
## 1 Neither agree nor disagree Neither agree nor disagree
## 2                      Agree             Agree strongly
## 3             Agree strongly                      Agree
## 4 Neither agree nor disagree                      Agree
## 5 Neither agree nor disagree                      Agree
## 6                      Agree                   Disagree
##                      ctinplt            stcbg2t       tmprs     caplcst
## 1                      Agree   Suspended prison        <NA>      Likely
## 2             Agree strongly     Other sentence        <NA> Very likely
## 3 Neither agree nor disagree    Prison sentence 7-11 months Very likely
## 4                   Disagree Community sentence        <NA> Very likely
## 5                      Agree Community sentence        <NA> Very likely
## 6             Agree strongly               Fine        <NA> Very likely
##            widprsn           wevdct flsin5y bstln5y troff5y hhmmb   gndr
## 1 Not very willing          Willing   Never    Once   Never     5   Male
## 2     Very willing     Very willing   Never   Never    Once     8   Male
## 3     Very willing Not very willing   Never   Never   Never     1 Female
## 4     Very willing          Willing   Never   Never   Twice     2 Female
## 5     Very willing     Very willing   Never   Never   Never     2 Female
## 6     Very willing     Very willing   Never   Never   Never     3 Female
##    gndr2  gndr3  gndr4  gndr5 gndr6  gndr7 gndr8 gndr9 gndr10 gndr11
## 1   Male Female   Male Female  <NA>   <NA>  <NA>  <NA>   <NA>   <NA>
## 2 Female   Male Female Female  Male Female  Male  <NA>   <NA>   <NA>
## 3   <NA>   <NA>   <NA>   <NA>  <NA>   <NA>  <NA>  <NA>   <NA>   <NA>
## 4   Male   <NA>   <NA>   <NA>  <NA>   <NA>  <NA>  <NA>   <NA>   <NA>
## 5   Male   <NA>   <NA>   <NA>  <NA>   <NA>  <NA>  <NA>   <NA>   <NA>
## 6   Male   Male   <NA>   <NA>  <NA>   <NA>  <NA>  <NA>   <NA>   <NA>
##   gndr12 gndr13 gndr14 yrbrn agea yrbrn2 yrbrn3 yrbrn4 yrbrn5 yrbrn6
## 1   <NA>   <NA>   <NA>  1988   22   1960   1965   1992   1993   <NA>
## 2   <NA>   <NA>   <NA>  1967   43   1969   1996   1998   1999   2007
## 3   <NA>   <NA>   <NA>  1991   19   <NA>   <NA>   <NA>   <NA>   <NA>
## 4   <NA>   <NA>   <NA>  1987   23   1974   <NA>   <NA>   <NA>   <NA>
## 5   <NA>   <NA>   <NA>  1952   58   1949   <NA>   <NA>   <NA>   <NA>
## 6   <NA>   <NA>   <NA>  1948   62   1946   1985   <NA>   <NA>   <NA>
##   yrbrn7 yrbrn8 yrbrn9 yrbrn10 yrbrn11 yrbrn12 yrbrn13 yrbrn14
## 1   <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2   2008   2010   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 3   <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 4   <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 5   <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 6   <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##                              rshipa2                          rshipa3
## 1 Brother/sister/step/adopted/foster             Parent/parent-in-law
## 2               Husband/wife/partner Son/daughter/step/adopted/foster
## 3                               <NA>                             <NA>
## 4               Husband/wife/partner                             <NA>
## 5               Husband/wife/partner                             <NA>
## 6               Husband/wife/partner Son/daughter/step/adopted/foster
##                              rshipa4                            rshipa5
## 1 Brother/sister/step/adopted/foster Brother/sister/step/adopted/foster
## 2   Son/daughter/step/adopted/foster   Son/daughter/step/adopted/foster
## 3                               <NA>                               <NA>
## 4                               <NA>                               <NA>
## 5                               <NA>                               <NA>
## 6                               <NA>                               <NA>
##                            rshipa6                          rshipa7
## 1                             <NA>                             <NA>
## 2 Son/daughter/step/adopted/foster Son/daughter/step/adopted/foster
## 3                             <NA>                             <NA>
## 4                             <NA>                             <NA>
## 5                             <NA>                             <NA>
## 6                             <NA>                             <NA>
##                            rshipa8 rshipa9 rshipa10 rshipa11 rshipa12
## 1                             <NA>    <NA>     <NA>     <NA>     <NA>
## 2 Son/daughter/step/adopted/foster    <NA>     <NA>     <NA>     <NA>
## 3                             <NA>    <NA>     <NA>     <NA>     <NA>
## 4                             <NA>    <NA>     <NA>     <NA>     <NA>
## 5                             <NA>    <NA>     <NA>     <NA>     <NA>
## 6                             <NA>    <NA>     <NA>     <NA>     <NA>
##   rshipa13 rshipa14                                    icpart1
## 1     <NA>     <NA>                                   Does not
## 2     <NA>     <NA> Respondent lives with husband/wife/partner
## 3     <NA>     <NA>                                   Does not
## 4     <NA>     <NA> Respondent lives with husband/wife/partner
## 5     <NA>     <NA> Respondent lives with husband/wife/partner
## 6     <NA>     <NA> Respondent lives with husband/wife/partner
##                                           rshpsts lvgptnea dvrcdeva
## 1                                            <NA>       No       No
## 2                                 Legally married      Yes      Yes
## 3                                            <NA>       No       No
## 4 Living with my partner - not legally recognised     <NA>       No
## 5                                 Legally married       No       No
## 6                                 Legally married       No       No
##                                      icpart2               iccohbt
## 1                                   Does not                  <NA>
## 2 Respondent lives with husband/wife/partner            All others
## 3                                   Does not                  <NA>
## 4 Respondent lives with husband/wife/partner Respondent cohabiting
## 5 Respondent lives with husband/wife/partner            All others
## 6 Respondent lives with husband/wife/partner            All others
##                                                               marsts
## 1 None of these (NEVER married or in legally registered civil union)
## 2                                                               <NA>
## 3 None of these (NEVER married or in legally registered civil union)
## 4 None of these (NEVER married or in legally registered civil union)
## 5                                                               <NA>
## 6                                                               <NA>
##   marstie
## 1    <NA>
## 2    <NA>
## 3    <NA>
## 4    <NA>
## 5    <NA>
## 6    <NA>
##                                                             maritalb
## 1 None of these (NEVER married or in legally registered civil union)
## 2                                                    Legally married
## 3 None of these (NEVER married or in legally registered civil union)
## 4 None of these (NEVER married or in legally registered civil union)
## 5                                                    Legally married
## 6                                                    Legally married
##                                             chldhm chldhhe fxltph
## 1                                         Does not      No     No
## 2 Respondent lives with children at household grid    <NA>     No
## 3                                         Does not      No     No
## 4                                         Does not      No     No
## 5                                         Does not     Yes    Yes
## 6 Respondent lives with children at household grid    <NA>    Yes
##                            domicil
## 1                       A big city
## 2               Town or small city
## 3                       A big city
## 4                       A big city
## 5 Suburbs or outskirts of big city
## 6 Suburbs or outskirts of big city
##                                                         edulvlb
## 1         Vocational ISCED 3A, access upper tier ISCED 5A/all 5
## 2 ISCED 5A medium, bachelor/equivalent from lower tier tertiary
## 3             Vocational ISCED 3C >= 2 years, no access ISCED 5
## 4 ISCED 5A medium, bachelor/equivalent from lower tier tertiary
## 5 ISCED 5A medium, bachelor/equivalent from lower tier tertiary
## 6 ISCED 5A medium, bachelor/equivalent from lower tier tertiary
##                                            eisced
## 1       ES-ISCED IIIa, upper tier upper secondary
## 2 ES-ISCED V1, lower tertiary education, BA level
## 3       ES-ISCED IIIb, lower tier upper secondary
## 4 ES-ISCED V1, lower tertiary education, BA level
## 5 ES-ISCED V1, lower tertiary education, BA level
## 6 ES-ISCED V1, lower tertiary education, BA level
##                                                                                                                    edlvdbe
## 1         Diploma van het secundair onderwijs (TSO of KSO); Diploma van het hoger secundair technisch (of kunst) onderwijs
## 2 Diploma hogescholenonderwijs van 1 cyclus: graduaat of professionele bachelor; Voortgezette opleiding volgend op hogesch
## 3           Studiegetuigschrift van secundair onderwijs (na 6e jaar BSO), Diploma van het hoger secundair beroepsonderwijs
## 4 Diploma hogescholenonderwijs van 1 cyclus: graduaat of professionele bachelor; Voortgezette opleiding volgend op hogesch
## 5 Diploma hogescholenonderwijs van 1 cyclus: graduaat of professionele bachelor; Voortgezette opleiding volgend op hogesch
## 6 Diploma hogescholenonderwijs van 1 cyclus: graduaat of professionele bachelor; Voortgezette opleiding volgend op hogesch
##   edlvdbg edlvdch edlvdhr edlvdcy edlvdcz edude1 edude2 edude3 edlvddk
## 1    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
## 2    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
## 3    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
## 4    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
## 5    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
## 6    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>   <NA>    <NA>
##   edlvdee edlvdes edlvdfi edlvdfr edugb1 edugb2 edagegb edlvdgr edlvdhu
## 1    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
## 2    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
## 3    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
## 4    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
## 5    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
## 6    <NA>    <NA>    <NA>    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>
##   edlvdie eduil1 eduil2 edlvdlt edlvdnl edlvdno edlvdpl eduyrpl edupl2
## 1    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
## 2    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
## 3    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
## 4    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
## 5    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
## 6    <NA>   <NA>   <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   <NA>
##   edlvdpt edlvdru edlvdse edlvdsi edlvdsk edlvdua eduyrs      pdwrk
## 1    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     15 Not marked
## 2    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     15     Marked
## 3    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     13 Not marked
## 4    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     15     Marked
## 5    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     15 Not marked
## 6    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>     13 Not marked
##        edctn     uempla     uempli      dsbld       rtrd      cmsrv
## 1 Not marked     Marked Not marked Not marked Not marked Not marked
## 2 Not marked Not marked Not marked Not marked Not marked Not marked
## 3     Marked Not marked Not marked Not marked Not marked Not marked
## 4     Marked Not marked Not marked Not marked Not marked Not marked
## 5 Not marked Not marked     Marked Not marked Not marked Not marked
## 6 Not marked Not marked Not marked Not marked     Marked Not marked
##        hswrk     dngoth      dngdk     dngref      dngna   mainact
## 1 Not marked Not marked Not marked Not marked Not marked      <NA>
## 2 Not marked Not marked Not marked Not marked Not marked      <NA>
## 3 Not marked Not marked Not marked Not marked Not marked      <NA>
## 4 Not marked Not marked Not marked Not marked Not marked Paid work
## 5 Not marked Not marked Not marked Not marked Not marked      <NA>
## 6 Not marked Not marked Not marked Not marked Not marked      <NA>
##                           mnactic crpdwk pdjobev pdjobyr  emplrel emplno
## 1     Unemployed, looking for job     No     Yes    2009 Employee   <NA>
## 2                       Paid work   <NA>    <NA>    <NA> Employee   <NA>
## 3                       Education    Yes    <NA>    <NA> Employee   <NA>
## 4                       Paid work   <NA>    <NA>    <NA> Employee   <NA>
## 5 Unemployed, not looking for job    Yes    <NA>    <NA> Employee   <NA>
## 6                         Retired     No     Yes    2008 Employee   <NA>
##     wrkctra                                              jbtmppm    estsz
## 1   Limited Temporary/fixed term job lasting less than 12 months Under 10
## 2   Limited                                                Other Under 10
## 3 Unlimited                                                 <NA> Under 10
## 4 Unlimited                                                 <NA> 10 to 24
## 5 Unlimited                                                 <NA> 25 to 99
## 6 Unlimited                                                 <NA> 10 to 24
##   jbspv njbspv                wkdcorga                 iorgact
## 1    No   <NA> I have/had no influence I have/had no influence
## 2    No   <NA>                       5                       5
## 3   Yes      2 I have/had no influence I have/had no influence
## 4    No   <NA>                       4                       2
## 5   Yes     50                       8                       7
## 6    No   <NA>                       9                       9
##                   wkdcpce wkhct wkhtot
## 1 I have/had no influence    38     38
## 2                       4    36     30
## 3 I have/had no influence     8     12
## 4                       5    30     33
## 5 I have/had no influence    38     50
## 6                       8    30     42
##                                                   nacer2
## 1 Retail trade, except of motor vehicles and motorcycles
## 2         Services to buildings and landscape activities
## 3 Retail trade, except of motor vehicles and motorcycles
## 4                                Human health activities
## 5                                Manufacture of textiles
## 6                                              Education
##                                              tporgwk
## 1                                     A private firm
## 2                                     A private firm
## 3                                     A private firm
## 4 Other public sector (such as education and health)
## 5                                     A private firm
## 6                           A state owned enterprise
##                                       iscoco                    rsnlvem
## 1                        Other office clerks             Contract ended
## 2              Domestic helpers and cleaners Personal or family reasons
## 3 Shop,stall,market salespers, demonstrators      Obtained a better job
## 4        Nursing and midwifery professionals     Never left an employer
## 5                  Managers in manufacturing      Obtained a better job
## 6   Primary education teaching professionals                    Retired
##   wrkac6m uemp3m uemp12m uemp5yr          mbtru
## 1      No     No    <NA>    <NA> Yes, currently
## 2     Yes    Yes     Yes     Yes Yes, currently
## 3      No     No    <NA>    <NA>             No
## 4      No     No    <NA>    <NA>             No
## 5      No     No    <NA>    <NA> Yes, currently
## 6      No     No    <NA>    <NA> Yes, currently
##                              hincsrca        hinctnta      pphincr
## 1                   Wages or salaries            <NA>   Very small
## 2                   Wages or salaries  F - 5th decile  Over a half
## 3 Any other social benefits or grants  J - 1st decile          All
## 4                   Wages or salaries H - 10th decile   About half
## 5                            Pensions  S - 6th decile Under a half
## 6                            Pensions  F - 5th decile   Very large
##                                hincfel                     brwmny
## 1             Coping on present income Neither easy nor difficult
## 2          Difficult on present income             Very difficult
## 3          Difficult on present income             Very difficult
## 4 Living comfortably on present income                 Quite easy
## 5 Living comfortably on present income Neither easy nor difficult
## 6 Living comfortably on present income            Quite difficult
##                                      icpart3
## 1                                   Does not
## 2 Respondent lives with husband/wife/partner
## 3                                   Does not
## 4 Respondent lives with husband/wife/partner
## 5 Respondent lives with husband/wife/partner
## 6 Respondent lives with husband/wife/partner
##                                                           edulvlpb
## 1                                                             <NA>
## 2                Vocational ISCED 3C >= 2 years, no access ISCED 5
## 3                                                             <NA>
## 4 ISCED 5A long, master/equivalent from upper/single tier tertiary
## 5                        ISCED 4 programmes without access ISCED 5
## 6               General ISCED 3A, access upper tier ISCED 5A/all 5
##                                               eiscedp
## 1                                                <NA>
## 2           ES-ISCED IIIb, lower tier upper secondary
## 3                                                <NA>
## 4 ES-ISCED V2, higher tertiary education, >= MA level
## 5        ES-ISCED IV, advanced vocational, sub-degree
## 6           ES-ISCED IIIa, upper tier upper secondary
##                                                                                                                   edlvpdbe
## 1                                                                                                                     <NA>
## 2           Studiegetuigschrift van secundair onderwijs (na 6e jaar BSO), Diploma van het hoger secundair beroepsonderwijs
## 3                                                                                                                     <NA>
## 4             Universitair diploma van licentiaat of master; Diploma van doctor, ingenieur (universitair), apotheker, arts
## 5 Studiegetuigschrift van het 3de leerjaar van de 3de graad TSO, KSO of BSO; 4de graad BSO; Diploma 'Ondernemersopleiding'
## 6                            Diploma van het secundair onderwijs (ASO), Diploma van het hoger algemeen secundair onderwijs
##   edlvpdbg edlvpdch edlvpdhr edlvpdcy edlvpdcz edupde1 edupde2 edupde3
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
##   edlvpddk edlvpdee edlvpdes edlvpdfi edlvpdfr edupgb1 edupgb2 edagepgb
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
##   edlvpdgr edlvpdhu edlvpdie edupil1 edupil2 edlvpdlt edlvpdnl edlvpdno
## 1     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
##   edlvpdpl eduyrppl eduppl2 edlvpdpt edlvpdru edlvpdse edlvpdsi edlvpdsk
## 1     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
##   edlvpdua     pdwrkp     edctnp    uemplap    uemplip     dsbldp
## 1     <NA> Not marked Not marked Not marked Not marked Not marked
## 2     <NA> Not marked Not marked Not marked Not marked Not marked
## 3     <NA> Not marked Not marked Not marked Not marked Not marked
## 4     <NA>     Marked Not marked Not marked Not marked Not marked
## 5     <NA> Not marked Not marked Not marked Not marked Not marked
## 6     <NA> Not marked Not marked Not marked Not marked Not marked
##        rtrdp     cmsrvp     hswrkp    dngothp     dngdkp    dngnapp
## 1 Not marked Not marked Not marked Not marked Not marked     Marked
## 2 Not marked Not marked     Marked Not marked Not marked Not marked
## 3 Not marked Not marked Not marked Not marked Not marked     Marked
## 4 Not marked Not marked Not marked Not marked Not marked Not marked
## 5     Marked Not marked Not marked Not marked Not marked Not marked
## 6     Marked Not marked Not marked Not marked Not marked Not marked
##      dngrefp     dngnap mnactp crpdwkp         iscocop       emprelp
## 1 Not marked Not marked   <NA>    <NA>            <NA>          <NA>
## 2 Not marked Not marked   <NA>      No            <NA>          <NA>
## 3 Not marked Not marked   <NA>    <NA>            <NA>          <NA>
## 4 Not marked Not marked   <NA>    <NA> Medical doctors Self-employed
## 5 Not marked Not marked   <NA>      No            <NA>          <NA>
## 6 Not marked Not marked   <NA>      No            <NA>          <NA>
##   emplnop jbspvp njbspvp wkhtotp
## 1    <NA>   <NA>    <NA>    <NA>
## 2    <NA>   <NA>    <NA>    <NA>
## 3    <NA>   <NA>    <NA>    <NA>
## 4    <NA>    Yes    <NA>      40
## 5    <NA>   <NA>    <NA>    <NA>
## 6    <NA>   <NA>    <NA>    <NA>
##                                                           edulvlfb
## 1            Vocational ISCED 3A, access upper tier ISCED 5A/all 5
## 2 ISCED 5A long, master/equivalent from upper/single tier tertiary
## 3                                                             <NA>
## 4            Vocational ISCED 3A, access upper tier ISCED 5A/all 5
## 5            Vocational ISCED 3A, access upper tier ISCED 5A/all 5
## 6                Vocational ISCED 2A/2B, access ISCED 3 vocational
##                                               eiscedf
## 1           ES-ISCED IIIa, upper tier upper secondary
## 2 ES-ISCED V2, higher tertiary education, >= MA level
## 3                                                <NA>
## 4           ES-ISCED IIIa, upper tier upper secondary
## 5           ES-ISCED IIIa, upper tier upper secondary
## 6                        ES-ISCED II, lower secondary
##                                                                                                           edlvfdbe
## 1 Diploma van het secundair onderwijs (TSO of KSO); Diploma van het hoger secundair technisch (of kunst) onderwijs
## 2     Universitair diploma van licentiaat of master; Diploma van doctor, ingenieur (universitair), apotheker, arts
## 3                                                                                                             <NA>
## 4 Diploma van het secundair onderwijs (TSO of KSO); Diploma van het hoger secundair technisch (of kunst) onderwijs
## 5 Diploma van het secundair onderwijs (TSO of KSO); Diploma van het hoger secundair technisch (of kunst) onderwijs
## 6                                                                Lager beroepsonderwijs, Lager technisch onderwijs
##   edlvfdbg edlvfdch edlvfdhr edlvfdcy edlvfdcz edufde1 edufde2 edufde3
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
##   edlvfddk edlvfdee edlvfdes edlvfdfi edlvfdfr edufgb1 edufgb2 edagefgb
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
##   edlvfdgr edlvfdhu edlvfdie edufil1 edufil2 edlvfdlt edlvfdnl edlvfdno
## 1     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
##   edlvfdpl edlvfdpt edlvfdru edlvfdse edlvfdsi edlvfdsk edlvfdua
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
##              emprf14 emplnof jbspvf                                occf14b
## 1           Employee    <NA>     No                    Semi-skilled worker
## 2           Employee    <NA>    Yes       Higher administrator occupations
## 3 Father dead/absent    <NA>   <NA>                                   <NA>
## 4           Employee    <NA>    Yes Professional and technical occupations
## 5           Employee    <NA>    Yes                         Skilled worker
## 6        Not working    <NA>   <NA>                                   <NA>
##                                                        edulvlmb
## 1                                   Not completed ISCED level 1
## 2             Vocational ISCED 3C >= 2 years, no access ISCED 5
## 3                          ISCED 1, completed primary education
## 4 ISCED 5A medium, bachelor/equivalent from lower tier tertiary
## 5                          ISCED 1, completed primary education
## 6             Vocational ISCED 2A/2B, access ISCED 3 vocational
##                                           eiscedm
## 1          ES-ISCED I , less than lower secondary
## 2       ES-ISCED IIIb, lower tier upper secondary
## 3          ES-ISCED I , less than lower secondary
## 4 ES-ISCED V1, lower tertiary education, BA level
## 5          ES-ISCED I , less than lower secondary
## 6                    ES-ISCED II, lower secondary
##                                                                                                                   edlvmdbe
## 1                                                                                            Niet voltooid lager onderwijs
## 2           Studiegetuigschrift van secundair onderwijs (na 6e jaar BSO), Diploma van het hoger secundair beroepsonderwijs
## 3                                                                                             Getuigschrift Basisonderwijs
## 4 Diploma hogescholenonderwijs van 1 cyclus: graduaat of professionele bachelor; Voortgezette opleiding volgend op hogesch
## 5                                                                                             Getuigschrift Basisonderwijs
## 6                                                                        Lager beroepsonderwijs, Lager technisch onderwijs
##   edlvmdbg edlvmdch edlvmdhr edlvmdcy edlvmdcz edumde1 edumde2 edumde3
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>    <NA>
##   edlvmddk edlvmdee edlvmdes edlvmdfi edlvmdfr edumgb1 edumgb2 edagemgb
## 1     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>
##   edlvmdgr edlvmdhu edlvmdie edumil1 edumil2 edlvmdlt edlvmdnl edlvmdno
## 1     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>    <NA>    <NA>     <NA>     <NA>     <NA>
##   edlvmdpl edlvmdpt edlvmdru edlvmdse edlvmdsi edlvmdsk edlvmdua
## 1     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
##         emprm14 emplnom jbspvm                                occm14b
## 1   Not working    <NA>   <NA>                                   <NA>
## 2 Self-employed    None   <NA>                      Sales occupations
## 3   Not working    <NA>   <NA>                                   <NA>
## 4      Employee    <NA>     No Professional and technical occupations
## 5   Not working    <NA>   <NA>                                   <NA>
## 6   Not working    <NA>   <NA>                                   <NA>
##   atncrse edul12m      useknwl edupdem                     gdsprt
## 1      No    <NA>         <NA>    <NA> Less than half of the time
## 2      No    <NA>         <NA>    <NA> More than half of the time
## 3      No    <NA>         <NA>    <NA>           Most of the time
## 4     Yes      60 Quite useful    None           Most of the time
## 5      No    <NA>         <NA>    <NA>            All of the time
## 6      No    <NA>         <NA>    <NA> Less than half of the time
##                       clmrlx                    actvgrs
## 1 Less than half of the time Less than half of the time
## 2 More than half of the time More than half of the time
## 3 Less than half of the time Less than half of the time
## 4           Some of the time           Most of the time
## 5 More than half of the time            All of the time
## 6           Most of the time           Most of the time
##                      wmcpwrk           mnrgtjb        gvprppv
## 1                   Disagree          Disagree          Agree
## 2 Neither agree nor disagree          Disagree Agree strongly
## 3          Disagree strongly Disagree strongly          Agree
## 4                   Disagree Disagree strongly Agree strongly
## 5                   Disagree          Disagree          Agree
## 6                   Disagree Disagree strongly Agree strongly
##                           fltlnla      mlohinc    dsdclve      cuthheq
## 1 None or almost none of the time            1          1            1
## 2                Some of the time            2          3            3
## 3                Some of the time A great deal Not at all A great deal
## 4 None or almost none of the time            3          1   Not at all
## 5                Some of the time   Not at all Not at all   Not at all
## 6                Some of the time            2          5 A great deal
##               yrspdwka      icmnact
## 1                    1   All others
## 2                   18 In paid work
## 3 Never had a paid job   All others
## 4                    2 In paid work
## 5                   32   All others
## 6                   41      Retired
##                                                        jbtsktm yrskdwk
## 1                                                         <NA>    <NA>
## 2 Working with physical objects and/or other physical material       1
## 3                                                         <NA>    <NA>
## 4                     Working with people other than employees       2
## 5                                                         <NA>    <NA>
## 6                                                         <NA>    <NA>
##                wrkengt     wkovrtm                 wrkwe yrcremp   emplrjb
## 1                 <NA>        <NA>                  <NA>    <NA>      <NA>
## 2          Once a week       Never Several times a month    2009  No, none
## 3                 <NA>        <NA>                  <NA>    <NA>      <NA>
## 4 Several times a week Once a week Several times a month    2008 Yes, many
## 5                 <NA>        <NA>                  <NA>    <NA>      <NA>
## 6                 <NA>        <NA>                  <NA>    <NA>      <NA>
##                                         mnrsefw
## 1                                          <NA>
## 2 It is everyone's duty to always do their best
## 3                                          <NA>
## 4 It is everyone's duty to always do their best
## 5                                          <NA>
## 6                                          <NA>
##                              scrsefw jbcoedu       jbedyrs         jblrn
## 1                               <NA>    <NA>          <NA>          <NA>
## 2                        Keep my job      No          <NA> 1 day or less
## 3                               <NA>    <NA>          <NA>          <NA>
## 4 My work is useful for other people     Yes About 3 years    1-3 months
## 5                               <NA>    <NA>          <NA>          <NA>
## 6                               <NA>    <NA>          <NA>          <NA>
##           vrtywrk         jbrqlrn         wgdpeft         hlpcowk
## 1            <NA>            <NA>            <NA>            <NA>
## 2 Not at all true Not at all true Not at all true Not at all true
## 3            <NA>            <NA>            <NA>            <NA>
## 4      Quite true   A little true Not at all true      Quite true
## 5            <NA>            <NA>            <NA>            <NA>
## 6            <NA>            <NA>            <NA>            <NA>
##         hlthrwk         dcsfwrk           jbscr         lsintjb
## 1          <NA>            <NA>            <NA>            <NA>
## 2     Very true Not at all true Not at all true Not at all true
## 3          <NA>            <NA>            <NA>            <NA>
## 4 A little true Not at all true   A little true Not at all true
## 5          <NA>            <NA>            <NA>            <NA>
## 6          <NA>            <NA>            <NA>            <NA>
##           wrkhrd                    nevdnjb                     oprtad
## 1           <NA>                       <NA>                       <NA>
## 2 Agree strongly Neither agree nor disagree             Agree strongly
## 3           <NA>                       <NA>                       <NA>
## 4 Agree strongly Neither agree nor disagree Neither agree nor disagree
## 5           <NA>                       <NA>                       <NA>
## 6           <NA>                       <NA>                       <NA>
##    bsmw     ppwwkp bseftwk smblvjb rpljbde wpmwkcp indisdc
## 1  <NA>       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2   Man About half       4       5       5      No    <NA>
## 3  <NA>       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 4 Woman Very large       3       8       2      No    <NA>
## 5  <NA>       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 6  <NA>       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##                    truinwk           pdaprpa   wrywprb   trdawrk   jbprtfp
## 1                     <NA>              <NA>      <NA>      <NA>      <NA>
## 2 Not much or no influence          Disagree    Always Sometimes     Never
## 3                     <NA>              <NA>      <NA>      <NA>      <NA>
## 4 Not much or no influence Disagree strongly Sometimes Sometimes Sometimes
## 5                     <NA>              <NA>      <NA>      <NA>      <NA>
## 6                     <NA>              <NA>      <NA>      <NA>      <NA>
##     icnopfma    pfmfdjba     frsptjb    dfcnswka stfmjob stfjbot  wkjbndm
## 1       <NA>        <NA>        <NA>        <NA>    <NA>    <NA>     <NA>
## 2 All others       Never       Never       Never       1       1 Disagree
## 3       <NA>        <NA>        <NA>        <NA>    <NA>    <NA>     <NA>
## 4 All others Hardly ever Hardly ever Hardly ever       7       5    Agree
## 5       <NA>        <NA>        <NA>        <NA>    <NA>    <NA>     <NA>
## 6       <NA>        <NA>        <NA>        <NA>    <NA>    <NA>     <NA>
##   grspaya        payprda linwk3y rdpay3y wkshr3y lscjb3y
## 1    <NA>           <NA>    <NA>    <NA>    <NA>    <NA>
## 2    1400     Four weeks     Yes     Yes     Yes      No
## 3    <NA>           <NA>    <NA>    <NA>    <NA>    <NA>
## 4    1400 Calendar month     Yes      No     Yes      No
## 5    <NA>           <NA>    <NA>    <NA>    <NA>    <NA>
## 6    <NA>           <NA>    <NA>    <NA>    <NA>    <NA>
##                         orgfd3y            npemp3y
## 1                          <NA>               <NA>
## 2                          <NA>               <NA>
## 3                          <NA>               <NA>
## 4 Not much financial difficulty Decreased a little
## 5                          <NA>               <NA>
## 6                          <NA>               <NA>
##                    icagu70a              ipjbini        ipjbscr
## 1 Respondent under 70 years        Not important  Not important
## 2 Respondent under 70 years Not important at all      Important
## 3 Respondent under 70 years            Important Very important
## 4 Respondent under 70 years            Important Very important
## 5 Respondent under 70 years            Important      Important
## 6 Respondent under 70 years            Important Very important
##          ipjbhin        ipjbwfm        ipjbtro                    pdjbndm
## 1 Very important      Important      Important Neither agree nor disagree
## 2      Important      Important      Important             Agree strongly
## 3 Very important Very important      Important Neither agree nor disagree
## 4      Important Very important Very important                      Agree
## 5      Important      Important      Important                      Agree
## 6 Very important Very important Very important             Agree strongly
##                        uemp3y wkhsch                           icptn
## 1                           1   <NA>                        Does not
## 2                          24     40 Lives with husband/wife/partner
## 3 Not unemployed last 3 years     32                        Does not
## 4 Not unemployed last 3 years     30 Lives with husband/wife/partner
## 5                          36     20 Lives with husband/wife/partner
## 6 Not unemployed last 3 years   <NA> Lives with husband/wife/partner
##   pwkhsch                                    puemp3y hwwkhs phwwkhs
## 1    <NA>                                       <NA>   <NA>    <NA>
## 2      30 Partner not unemployed in the last 3 years      8      20
## 3    <NA>                                       <NA>   <NA>    <NA>
## 4      40 Partner not unemployed in the last 3 years      9       5
## 5      20 Partner not unemployed in the last 3 years     16      16
## 6       0 Partner not unemployed in the last 3 years     20       0
##                 dsgrmnya                    icptnwka              wkengtp
## 1                   <NA>                        <NA>                 <NA>
## 2 Less than once a month Partner is not in paid work                 <NA>
## 3                   <NA>                        <NA>                 <NA>
## 4 Less than once a month     Partner is in paid work Several times a week
## 5                  Never Partner is not in paid work                 <NA>
## 6   Several times a week Partner is not in paid work                 <NA>
##       wkovtmp               ptnwkwe                               icmnart
## 1        <NA>                  <NA>                            All others
## 2        <NA>                  <NA>                            All others
## 3        <NA>                  <NA>                            All others
## 4 Once a week Several times a month                            All others
## 5        <NA>                  <NA>                            All others
## 6        <NA>                  <NA> Respondent's main activity is retired
##   rtryr           wntrtr                        icago45 agertr
## 1  <NA>             <NA>                           <NA>   <NA>
## 2  <NA>             <NA> Respondent 45 years or younger   <NA>
## 3  <NA>             <NA> Respondent 45 years or younger   <NA>
## 4  <NA>             <NA> Respondent 45 years or younger   <NA>
## 5  <NA>             <NA>       Respondent over 45 years     60
## 6  2008 Wanted to retire       Respondent over 45 years     60
##          plnchld          ipcrtiv            imprich           ipeqopt
## 1           <NA> Somewhat like me   Somewhat like me  Somewhat like me
## 2 Definitely not Somewhat like me        Not like me  Somewhat like me
## 3   Probably not A little like me   A little like me           Like me
## 4 Definitely yes          Like me   A little like me Very much like me
## 5           <NA>          Like me        Not like me Very much like me
## 6           <NA> A little like me Not like me at all           Like me
##            ipshabt          impsafe          impdiff           ipfrule
## 1 Somewhat like me Somewhat like me A little like me  A little like me
## 2 Somewhat like me Somewhat like me          Like me       Not like me
## 3          Like me          Like me          Like me           Like me
## 4          Like me Somewhat like me          Like me       Not like me
## 5          Like me          Like me A little like me           Like me
## 6 A little like me          Like me          Like me Very much like me
##            ipudrst          ipmodst          ipgdtim           impfree
## 1 Somewhat like me Somewhat like me Somewhat like me           Like me
## 2          Like me      Not like me Somewhat like me           Like me
## 3          Like me          Like me          Like me           Like me
## 4          Like me          Like me Somewhat like me  Somewhat like me
## 5          Like me          Like me A little like me Very much like me
## 6          Like me          Like me      Not like me           Like me
##   iphlppl          ipsuces           ipstrgv          ipadvnt
## 1 Like me          Like me           Like me Somewhat like me
## 2 Like me          Like me           Like me          Like me
## 3 Like me          Like me           Like me      Not like me
## 4 Like me Somewhat like me  A little like me A little like me
## 5 Like me Somewhat like me           Like me      Not like me
## 6 Like me Somewhat like me Very much like me A little like me
##             ipbhprp            iprspot           iplylfr
## 1           Like me            Like me           Like me
## 2           Like me        Not like me       Not like me
## 3  Somewhat like me Not like me at all Very much like me
## 4  A little like me        Not like me Very much like me
## 5           Like me   A little like me           Like me
## 6 Very much like me        Not like me           Like me
##               impenv           imptrad           impfun
## 1            Like me           Like me Somewhat like me
## 2   Somewhat like me           Like me          Like me
## 3 Not like me at all  A little like me          Like me
## 4            Like me           Like me Somewhat like me
## 5            Like me  A little like me          Like me
## 6  Very much like me Very much like me      Not like me
##                  region      regunit intewde inwdds inwmms inwyys inwshh
## 1 Prov. Oost-Vlaanderen NUTS level 2    <NA>     20     11   2010     13
## 2 Prov. Oost-Vlaanderen NUTS level 2    <NA>      7     11   2010     14
## 3 Prov. Oost-Vlaanderen NUTS level 2    <NA>      4     11   2010     14
## 4 Prov. Oost-Vlaanderen NUTS level 2    <NA>     29     10   2010     11
## 5 Prov. Oost-Vlaanderen NUTS level 2    <NA>     29     10   2010     13
## 6 Prov. Oost-Vlaanderen NUTS level 2    <NA>     10     12   2010     14
##   inwsmm inwdde inwmme inwyye inwehh inwemm inwtm             spltadmd
## 1     36     20     11   2010     14      2    26 FF C testd26-testd39
## 2     10      7     11   2010     15     54   104  FF A testd1-testd12
## 3      5      4     11   2010     14     46    41  FF A testd1-testd12
## 4     11     29     10   2010     12      7    56 FF B testd13-testd25
## 5     30     29     10   2010     14     48    78 FF C testd26-testd39
## 6      4     10     12   2010     14     52    48 FF B testd13-testd25
##   supqad1                supqad2 supqdd supqmm supqyr dweight   pspwght
## 1    <NA> Face to face interview     20     11   2010       1 0.7928646
## 2    <NA> Face to face interview      7     11   2010       1 0.8711070
## 3    <NA> Face to face interview      4     11   2010       1 0.7994527
## 4    <NA> Face to face interview     29     10   2010       1 0.8160296
## 5    <NA> Face to face interview     29     10   2010       1 0.7649024
## 6    <NA> Face to face interview     10     12   2010       1 0.7649024
##     pweight
## 1 0.5286192
## 2 0.5286192
## 3 0.5286192
## 4 0.5286192
## 5 0.5286192
## 6 0.5286192
names(ESS)
##   [1] "name"     "essround" "edition"  "proddate" "idno"     "cntry"   
##   [7] "tvtot"    "tvpol"    "rdtot"    "rdpol"    "nwsptot"  "nwsppol" 
##  [13] "netuse"   "ppltrst"  "pplfair"  "pplhlp"   "polintr"  "trstprl" 
##  [19] "trstlgl"  "trstplc"  "trstplt"  "trstprt"  "trstep"   "trstun"  
##  [25] "vote"     "prtvtcbe" "prtvtbbg" "prtvtcch" "prtvthr"  "prtvtcy" 
##  [31] "prtvtbcz" "prtvcde1" "prtvcde2" "prtvtbdk" "prtvtcee" "prtvtbes"
##  [37] "prtvtbfi" "prtvtbfr" "prtvtgb"  "prtvtcgr" "prtvtchu" "prtvtaie"
##  [43] "prtvtbil" "prtvlt1"  "prtvlt2"  "prtvlt3"  "prtvtdnl" "prtvtano"
##  [49] "prtvtbpl" "prtvtbpt" "prtvtbru" "prtvtase" "prtvtcsi" "prtvtbsk"
##  [55] "prtvtbua" "contplt"  "wrkprty"  "wrkorg"   "badge"    "sgnptit" 
##  [61] "pbldmn"   "bctprd"   "clsprty"  "prtclcbe" "prtclbbg" "prtclcch"
##  [67] "prtclcy"  "prtclhr"  "prtclbcz" "prtclcde" "prtclbdk" "prtclcee"
##  [73] "prtclbes" "prtclbfi" "prtclcfr" "prtclgb"  "prtclcgr" "prtclchu"
##  [79] "prtclcie" "prtclbil" "prtcllt"  "prtclcnl" "prtclano" "prtcldpl"
##  [85] "prtclcpt" "prtclbru" "prtclase" "prtclcsi" "prtclbsk" "prtclcua"
##  [91] "prtdgcl"  "mmbprty"  "prtmbcbe" "prtmbbbg" "prtmbcch" "prtmbhr" 
##  [97] "prtmbcy"  "prtmbbcz" "prtmbcde" "prtmbbdk" "prtmbcee" "prtmbbes"
## [103] "prtmbbfi" "prtmbcfr" "prtmbgb"  "prtmbcgr" "prtmbchu" "prtmbbie"
## [109] "prtmbbil" "prtmblt"  "prtmbcnl" "prtmbano" "prtmbdpl" "prtmbbpt"
## [115] "prtmbbru" "prtmbase" "prtmbcsi" "prtmbbsk" "prtmbcua" "lrscale" 
## [121] "stflife"  "stfeco"   "stfgov"   "stfdem"   "stfedu"   "stfhlth" 
## [127] "gincdif"  "freehms"  "prtyban"  "scnsenv"  "imsmetn"  "imdfetn" 
## [133] "impcntr"  "imbgeco"  "imueclt"  "imwbcnt"  "happy"    "sclmeet" 
## [139] "inmdisc"  "sclact"   "crmvct"   "aesfdrk"  "brghmwr"  "brghmef" 
## [145] "crvctwr"  "crvctef"  "health"   "hlthhmp"  "rlgblg"   "rlgdnm"  
## [151] "rlgdnbe"  "rlgdnach" "rlgdncy"  "rlgdnde"  "rlgdndk"  "rlgdnafi"
## [157] "rlgdngb"  "rlgdnagr" "rlgdnhu"  "rlgdnie"  "rlgdnil"  "rlgdnlt" 
## [163] "rlgdnnl"  "rlgdnno"  "rlgdnapl" "rlgdnpt"  "rlgdnaru" "rlgdnase"
## [169] "rlgdnsi"  "rlgdnsk"  "rlgdnua"  "rlgblge"  "rlgdnme"  "rlgdebe" 
## [175] "rlgdeach" "rlgdecy"  "rlgdede"  "rlgdedk"  "rlgdeafi" "rlgdegb" 
## [181] "rlgdeagr" "rlgdehu"  "rlgdeie"  "rlgdeil"  "rlgdelt"  "rlgdenl" 
## [187] "rlgdeno"  "rlgdeapl" "rlgdept"  "rlgdearu" "rlgdease" "rlgdesi" 
## [193] "rlgdesk"  "rlgdeua"  "rlgdgr"   "rlgatnd"  "pray"     "dscrgrp" 
## [199] "dscrrce"  "dscrntn"  "dscrrlg"  "dscrlng"  "dscretn"  "dscrage" 
## [205] "dscrgnd"  "dscrsex"  "dscrdsb"  "dscroth"  "dscrdk"   "dscrref" 
## [211] "dscrnap"  "dscrna"   "ctzcntr"  "ctzshipb" "brncntr"  "cntbrthb"
## [217] "livecnta" "lnghom1"  "lnghom2"  "blgetmg"  "facntr"   "fbrncnta"
## [223] "mocntr"   "mbrncnta" "insclwr"  "bystlwr"  "trfowr"   "insclct" 
## [229] "bystlct"  "trfoct"   "plcjbcn"  "plccont"  "plcstf"   "plcvcrp" 
## [235] "plcvcrc"  "plcpvcr"  "plccbrg"  "plcarcr"  "plcrspc"  "plcfrdc" 
## [241] "plcexdc"  "bplcdc"   "doplcsy"  "dpcstrb"  "plcrgwr"  "plcipvl" 
## [247] "gsupplc"  "plciplt"  "plccbrb"  "ctjbcnt"  "ctmtgfr"  "ctfrdc"  
## [253] "wraccrp"  "wraccrc"  "jdgcbrb"  "ctprpwr"  "hrshsnta" "dbctvrd" 
## [259] "lwstrob"  "rgbrklw"  "ctinplt"  "stcbg2t"  "tmprs"    "caplcst" 
## [265] "widprsn"  "wevdct"   "flsin5y"  "bstln5y"  "troff5y"  "hhmmb"   
## [271] "gndr"     "gndr2"    "gndr3"    "gndr4"    "gndr5"    "gndr6"   
## [277] "gndr7"    "gndr8"    "gndr9"    "gndr10"   "gndr11"   "gndr12"  
## [283] "gndr13"   "gndr14"   "yrbrn"    "agea"     "yrbrn2"   "yrbrn3"  
## [289] "yrbrn4"   "yrbrn5"   "yrbrn6"   "yrbrn7"   "yrbrn8"   "yrbrn9"  
## [295] "yrbrn10"  "yrbrn11"  "yrbrn12"  "yrbrn13"  "yrbrn14"  "rshipa2" 
## [301] "rshipa3"  "rshipa4"  "rshipa5"  "rshipa6"  "rshipa7"  "rshipa8" 
## [307] "rshipa9"  "rshipa10" "rshipa11" "rshipa12" "rshipa13" "rshipa14"
## [313] "icpart1"  "rshpsts"  "lvgptnea" "dvrcdeva" "icpart2"  "iccohbt" 
## [319] "marsts"   "marstie"  "maritalb" "chldhm"   "chldhhe"  "fxltph"  
## [325] "domicil"  "edulvlb"  "eisced"   "edlvdbe"  "edlvdbg"  "edlvdch" 
## [331] "edlvdhr"  "edlvdcy"  "edlvdcz"  "edude1"   "edude2"   "edude3"  
## [337] "edlvddk"  "edlvdee"  "edlvdes"  "edlvdfi"  "edlvdfr"  "edugb1"  
## [343] "edugb2"   "edagegb"  "edlvdgr"  "edlvdhu"  "edlvdie"  "eduil1"  
## [349] "eduil2"   "edlvdlt"  "edlvdnl"  "edlvdno"  "edlvdpl"  "eduyrpl" 
## [355] "edupl2"   "edlvdpt"  "edlvdru"  "edlvdse"  "edlvdsi"  "edlvdsk" 
## [361] "edlvdua"  "eduyrs"   "pdwrk"    "edctn"    "uempla"   "uempli"  
## [367] "dsbld"    "rtrd"     "cmsrv"    "hswrk"    "dngoth"   "dngdk"   
## [373] "dngref"   "dngna"    "mainact"  "mnactic"  "crpdwk"   "pdjobev" 
## [379] "pdjobyr"  "emplrel"  "emplno"   "wrkctra"  "jbtmppm"  "estsz"   
## [385] "jbspv"    "njbspv"   "wkdcorga" "iorgact"  "wkdcpce"  "wkhct"   
## [391] "wkhtot"   "nacer2"   "tporgwk"  "iscoco"   "rsnlvem"  "wrkac6m" 
## [397] "uemp3m"   "uemp12m"  "uemp5yr"  "mbtru"    "hincsrca" "hinctnta"
## [403] "pphincr"  "hincfel"  "brwmny"   "icpart3"  "edulvlpb" "eiscedp" 
## [409] "edlvpdbe" "edlvpdbg" "edlvpdch" "edlvpdhr" "edlvpdcy" "edlvpdcz"
## [415] "edupde1"  "edupde2"  "edupde3"  "edlvpddk" "edlvpdee" "edlvpdes"
## [421] "edlvpdfi" "edlvpdfr" "edupgb1"  "edupgb2"  "edagepgb" "edlvpdgr"
## [427] "edlvpdhu" "edlvpdie" "edupil1"  "edupil2"  "edlvpdlt" "edlvpdnl"
## [433] "edlvpdno" "edlvpdpl" "eduyrppl" "eduppl2"  "edlvpdpt" "edlvpdru"
## [439] "edlvpdse" "edlvpdsi" "edlvpdsk" "edlvpdua" "pdwrkp"   "edctnp"  
## [445] "uemplap"  "uemplip"  "dsbldp"   "rtrdp"    "cmsrvp"   "hswrkp"  
## [451] "dngothp"  "dngdkp"   "dngnapp"  "dngrefp"  "dngnap"   "mnactp"  
## [457] "crpdwkp"  "iscocop"  "emprelp"  "emplnop"  "jbspvp"   "njbspvp" 
## [463] "wkhtotp"  "edulvlfb" "eiscedf"  "edlvfdbe" "edlvfdbg" "edlvfdch"
## [469] "edlvfdhr" "edlvfdcy" "edlvfdcz" "edufde1"  "edufde2"  "edufde3" 
## [475] "edlvfddk" "edlvfdee" "edlvfdes" "edlvfdfi" "edlvfdfr" "edufgb1" 
## [481] "edufgb2"  "edagefgb" "edlvfdgr" "edlvfdhu" "edlvfdie" "edufil1" 
## [487] "edufil2"  "edlvfdlt" "edlvfdnl" "edlvfdno" "edlvfdpl" "edlvfdpt"
## [493] "edlvfdru" "edlvfdse" "edlvfdsi" "edlvfdsk" "edlvfdua" "emprf14" 
## [499] "emplnof"  "jbspvf"   "occf14b"  "edulvlmb" "eiscedm"  "edlvmdbe"
## [505] "edlvmdbg" "edlvmdch" "edlvmdhr" "edlvmdcy" "edlvmdcz" "edumde1" 
## [511] "edumde2"  "edumde3"  "edlvmddk" "edlvmdee" "edlvmdes" "edlvmdfi"
## [517] "edlvmdfr" "edumgb1"  "edumgb2"  "edagemgb" "edlvmdgr" "edlvmdhu"
## [523] "edlvmdie" "edumil1"  "edumil2"  "edlvmdlt" "edlvmdnl" "edlvmdno"
## [529] "edlvmdpl" "edlvmdpt" "edlvmdru" "edlvmdse" "edlvmdsi" "edlvmdsk"
## [535] "edlvmdua" "emprm14"  "emplnom"  "jbspvm"   "occm14b"  "atncrse" 
## [541] "edul12m"  "useknwl"  "edupdem"  "gdsprt"   "clmrlx"   "actvgrs" 
## [547] "wmcpwrk"  "mnrgtjb"  "gvprppv"  "fltlnla"  "mlohinc"  "dsdclve" 
## [553] "cuthheq"  "yrspdwka" "icmnact"  "jbtsktm"  "yrskdwk"  "wrkengt" 
## [559] "wkovrtm"  "wrkwe"    "yrcremp"  "emplrjb"  "mnrsefw"  "scrsefw" 
## [565] "jbcoedu"  "jbedyrs"  "jblrn"    "vrtywrk"  "jbrqlrn"  "wgdpeft" 
## [571] "hlpcowk"  "hlthrwk"  "dcsfwrk"  "jbscr"    "lsintjb"  "wrkhrd"  
## [577] "nevdnjb"  "oprtad"   "bsmw"     "ppwwkp"   "bseftwk"  "smblvjb" 
## [583] "rpljbde"  "wpmwkcp"  "indisdc"  "truinwk"  "pdaprpa"  "wrywprb" 
## [589] "trdawrk"  "jbprtfp"  "icnopfma" "pfmfdjba" "frsptjb"  "dfcnswka"
## [595] "stfmjob"  "stfjbot"  "wkjbndm"  "grspaya"  "payprda"  "linwk3y" 
## [601] "rdpay3y"  "wkshr3y"  "lscjb3y"  "orgfd3y"  "npemp3y"  "icagu70a"
## [607] "ipjbini"  "ipjbscr"  "ipjbhin"  "ipjbwfm"  "ipjbtro"  "pdjbndm" 
## [613] "uemp3y"   "wkhsch"   "icptn"    "pwkhsch"  "puemp3y"  "hwwkhs"  
## [619] "phwwkhs"  "dsgrmnya" "icptnwka" "wkengtp"  "wkovtmp"  "ptnwkwe" 
## [625] "icmnart"  "rtryr"    "wntrtr"   "icago45"  "agertr"   "plnchld" 
## [631] "ipcrtiv"  "imprich"  "ipeqopt"  "ipshabt"  "impsafe"  "impdiff" 
## [637] "ipfrule"  "ipudrst"  "ipmodst"  "ipgdtim"  "impfree"  "iphlppl" 
## [643] "ipsuces"  "ipstrgv"  "ipadvnt"  "ipbhprp"  "iprspot"  "iplylfr" 
## [649] "impenv"   "imptrad"  "impfun"   "region"   "regunit"  "intewde" 
## [655] "inwdds"   "inwmms"   "inwyys"   "inwshh"   "inwsmm"   "inwdde"  
## [661] "inwmme"   "inwyye"   "inwehh"   "inwemm"   "inwtm"    "spltadmd"
## [667] "supqad1"  "supqad2"  "supqdd"   "supqmm"   "supqyr"   "dweight" 
## [673] "pspwght"  "pweight"

Let’s select variables for the analysis

library(dplyr)
## Warning: As of rlang 0.4.0, dplyr must be at least version 0.8.0.
## x dplyr 0.7.6 is too old for rlang 0.4.2.
## i Please update dplyr to the latest version.
## i Updating packages on Windows requires precautions:
##   <https://github.com/jennybc/what-they-forgot/issues/62>
ESS1 <- select(ESS, c("eduyrs", "agea", "agertr", "gndr", 
             "cntry", "icmnact", "facntr", "mocntr",
             "ipeqopt", "ipudrst", "impenv",
             "ipfrule", "ipbhprp", "impfun"))
dim(ESS1)
## [1] 52458    14

All the variables in our dataset

str(ESS1)
## 'data.frame':    52458 obs. of  14 variables:
##  $ eduyrs : Factor w/ 45 levels "0","1","2","3",..: 16 16 14 16 16 14 18 14 13 13 ...
##  $ agea   : Factor w/ 88 levels "14","15","16",..: 9 30 6 10 45 49 13 27 35 55 ...
##  $ agertr : Factor w/ 77 levels "0","1","2","5",..: NA NA NA NA 45 45 NA NA 43 46 ...
##  $ gndr   : Factor w/ 2 levels "Male","Female": 1 1 2 2 2 2 1 1 1 1 ...
##  $ cntry  : Factor w/ 27 levels "Belgium","Bulgaria",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ icmnact: Factor w/ 3 levels "In paid work",..: 3 1 3 1 3 2 1 1 1 2 ...
##  $ facntr : Factor w/ 2 levels "Yes","No": 2 2 1 1 1 1 1 1 1 1 ...
##  $ mocntr : Factor w/ 2 levels "Yes","No": 2 2 1 2 1 1 1 1 1 1 ...
##  $ ipeqopt: Factor w/ 6 levels "Very much like me",..: 3 3 2 1 1 2 3 5 2 2 ...
##  $ ipudrst: Factor w/ 6 levels "Very much like me",..: 3 2 2 2 2 2 3 5 3 2 ...
##  $ impenv : Factor w/ 6 levels "Very much like me",..: 2 3 6 2 2 1 4 5 2 2 ...
##  $ ipfrule: Factor w/ 6 levels "Very much like me",..: 4 5 2 5 2 1 5 5 3 4 ...
##  $ ipbhprp: Factor w/ 6 levels "Very much like me",..: 2 2 3 4 2 1 4 5 5 2 ...
##  $ impfun : Factor w/ 6 levels "Very much like me",..: 3 2 2 3 2 5 2 2 2 2 ...
##  - attr(*, "variable.labels")= Named chr  "Title of dataset" "ESS round" "Edition" "Production date" ...
##   ..- attr(*, "names")= chr  "name" "essround" "edition" "proddate" ...
##  - attr(*, "codepage")= int 65001

Let’s convert age to numeric variable

Why can’t we just use as.numeric()

class(ESS1$agea)
## [1] "factor"
table(ESS1$agea)
## 
##  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31 
##   1 306 572 651 765 675 700 774 708 718 710 746 727 686 734 771 789 880 
##  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49 
## 777 755 867 811 811 791 816 847 881 916 841 860 851 903 866 865 910 843 
##  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67 
## 909 909 876 857 898 887 896 827 856 912 867 948 943 806 844 758 778 708 
##  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85 
## 696 709 653 765 650 652 581 587 508 494 401 431 408 401 339 295 217 214 
##  86  87  88  89  90  91  92  93  94  95  96  97  98  99 101 102 
## 167 135 118  88  70  40  22  23  16   9   6   2   1   2   1   1
ESS1$agea_n <-  as.numeric(ESS1$agea)
table(ESS1$agea_n )
## 
##   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18 
##   1 306 572 651 765 675 700 774 708 718 710 746 727 686 734 771 789 880 
##  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36 
## 777 755 867 811 811 791 816 847 881 916 841 860 851 903 866 865 910 843 
##  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54 
## 909 909 876 857 898 887 896 827 856 912 867 948 943 806 844 758 778 708 
##  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72 
## 696 709 653 765 650 652 581 587 508 494 401 431 408 401 339 295 217 214 
##  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88 
## 167 135 118  88  70  40  22  23  16   9   6   2   1   2   1   1

So, we need to do as.character() first

ESS1$agea_n <-  as.numeric(as.character(ESS1$agea))
table(ESS1$agea_n)
## 
##  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31 
##   1 306 572 651 765 675 700 774 708 718 710 746 727 686 734 771 789 880 
##  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49 
## 777 755 867 811 811 791 816 847 881 916 841 860 851 903 866 865 910 843 
##  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67 
## 909 909 876 857 898 887 896 827 856 912 867 948 943 806 844 758 778 708 
##  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85 
## 696 709 653 765 650 652 581 587 508 494 401 431 408 401 339 295 217 214 
##  86  87  88  89  90  91  92  93  94  95  96  97  98  99 101 102 
## 167 135 118  88  70  40  22  23  16   9   6   2   1   2   1   1
class(ESS1$agea_n)
## [1] "numeric"

Let’s recode a variable: eduyrs

Why is that important to use as.character() before using as.numeric()

table(ESS1$eduyrs)
## 
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14 
##  289   98  166  433 1166  388 1443 1137 2968 3041 3647 5403 9125 4593 3578 
##   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29 
## 3646 3427 2522 1953  958  898  286  239  115   99  103   19   15   13    6 
##   30   31   32   33   34   35   36   37   40   42   43   45   47   50   55 
##   21    1    1    4    2    3    2    1   12    1    1    3    1    1    1
ESS1$eduyrs1 <- as.numeric(as.character(ESS1$eduyrs))
ESS1$eduyrs3 <- NULL
ESS1$eduyrs3[ESS1$eduyrs1 <= 10] <- "1 - basic" 
ESS1$eduyrs3[ESS1$eduyrs1 > 10 & ESS1$eduyrs1 <= 16] <- "2 - undergrads" 
ESS1$eduyrs3[ESS1$eduyrs1 > 16] <- "3 - grad" 
summary(ESS1$eduyrs3)
##    Length     Class      Mode 
##     52458 character character

Histogram: eduyrs

hist(ESS1$eduyrs1)

Barplot: eduyrs3

barplot(table(ESS1$eduyrs3))

Values variables

Let’s change a type of the variables

class(ESS1$ipeqopt) # should be numeric
## [1] "factor"
table(ESS1$ipeqopt)
## 
##  Very much like me            Like me   Somewhat like me 
##              17606              20502               8377 
##   A little like me        Not like me Not like me at all 
##               3207               1270                313
ESS1$ipeqopt <- as.numeric(ESS1$ipeqopt)
ESS1$ipudrst <- as.numeric(ESS1$ipudrst)
ESS1$impenv <- as.numeric(ESS1$impenv)

Let’s create an index

ESS1$Universalism <- (ESS1$ipeqopt + ESS1$ipudrst + ESS1$impenv)/3
summary(ESS1$Universalism)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   1.000   1.667   2.000   2.197   2.667   6.000    1866

How does the distribution of the index look like?

hist(ESS1$Universalism)

Let’s create a new variable: 2nd generation migrant

levels(ESS1$facntr)
## [1] "Yes" "No"
levels(ESS1$mocntr)
## [1] "Yes" "No"
ESS1$mig2 <- ifelse(ESS1$mocntr=="No" | ESS1$facntr=="No", 
                    1, 0)
summary(ESS1$mig2)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##  0.0000  0.0000  0.0000  0.1635  0.0000  1.0000     271
ESS1$mig2 <- factor(ESS1$mig2, labels = c("No", "Yes"), ordered=F)

Let’s recode and reverse another variable: impfun

summary(ESS1$impfun)
##  Very much like me            Like me   Somewhat like me 
##               6303              13650              12619 
##   A little like me        Not like me Not like me at all 
##               9198               6570               2791 
##               NA's 
##               1327
ESS1$impfun3 <- recode(ESS1$impfun, "Very much like me" = 3,
"Like me" = 3, "Somewhat like me" = 2, "A little like me" = 2, "Not like me" = 1, 
"Not like me at all" = 1)
summary(ESS1$impfun3)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   1.000   2.000   2.000   2.207   3.000   3.000    1327

Let’s recode another variable: barplot

barplot(table(ESS1$impfun3))

Central tendency measures: Mode, Median and Mean

median(ESS1$agea_n)
## [1] NA
median(ESS1$agea_n, na.rm = T)
## [1] 48
mean(ESS1$agea_n)
## [1] NA
mean(ESS1$agea_n, na.rm = T)
## [1] 48.50527

Create a “Mode” function

Mode <- function(x) {
  ux <- unique(x)
  ux[which.max(tabulate(match(x, ux)))]
}

Now let’s try the “Mode”. This measure can be applied to any type of variables

Mode(ESS1$agea)
## [1] 61
## 88 Levels: 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ... 102
Mode(ESS1$eduyrs3)
## [1] "2 - undergrads"

Variance measures

range(ESS1$agea_n)
## [1] NA NA
var(ESS1$agea_n)
## [1] NA
var(na.omit(ESS1$agea_n))
## [1] 353.0394
sd(ESS1$agea_n)
## [1] NA
sd(na.omit(ESS1$agea_n))
## [1] 18.78934

tapply()

tapply(ESS1$agea_n, ESS1$gndr, mean, na.rm=TRUE)
##     Male   Female 
## 47.54179 49.30844
tapply(ESS1$agea_n, ESS1$gndr, median, na.rm=TRUE)
##   Male Female 
##     47     49

Let’s answer a small research question

How age and ideal age of retirement are related to each other?

What should we do?

Let’s create a subsample

We are selecting only those respondents who are currently working

unique(ESS1$icmnact)
## [1] All others   In paid work Retired      <NA>        
## Levels: In paid work Retired All others
summary(ESS1$icmnact)
## In paid work      Retired   All others         NA's 
##        24049        14055        14220          134
ESS1sub <- subset(ESS1, subset=(icmnact=="In paid work"))

Let’s take a look at “agertr” and “age” variables

class(ESS1sub$agertr)
## [1] "factor"
class(ESS1sub$agea)
## [1] "factor"
summary(ESS1sub$agertr)
##     0     1     2     5     8     9    16    19    20    23    24    25 
##     0     0     0     1     0     1     0     0     0     0     0     0 
##    27    28    29    30    31    32    33    35    36    37    38    39 
##     0     0     0     4     0     0     0     3     0     0     0     0 
##    40    41    42    43    44    45    46    47    48    49    50    51 
##    12     0     0     2     1    25     7    10     8     7   344     9 
##    52    53    54    55    56    57    58    59    60    61    62    63 
##    31    31    25  1337    99   121   333    35  3323    53   601   449 
##    64    65    66    67    68    69    70    71    72    73    74    75 
##   116  1426    40   208    37     8   281     1     4     2     0    48 
##    76    77    78    80    81    82    84    85    86    87    88    90 
##     2     1     3    42     0     1     1    10     0     1     2     9 
##    96    99   100   102   120  NA's 
##     1     5     9     0     1 14918
summary(ESS1sub$agea)
##   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28 
##    0    1   11   18   53  107  143  231  260  329  376  429  429  471  502 
##   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43 
##  548  581  621  569  554  625  594  583  594  598  656  677  714  609  641 
##   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58 
##  646  686  672  659  690  655  644  627  635  580  587  589  566  477  464 
##   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73 
##  459  380  306  270  197  154  111   76   70   45   33   31   22   19   21 
##   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88 
##   14   14   10    8    7   10    4    4    5    2    1    1    2    0    1 
##   89   90   91   92   93   94   95   96   97   98   99  101  102 NA's 
##    0    0    0    0    0    0    0    0    0    0    0    0    0   71

Let’s make a plot

ESS1sub$agertr <- as.numeric(ESS1sub$agertr)
ESS1sub$agea <- as.numeric(ESS1sub$agea)
plot(ESS1sub$agea, ESS1sub$agertr, pch = 20)

Boxplot

Is average ideal age of retirement differs for males and females?

boxplot(ESS1sub$agertr ~ ESS1sub$gndr)

Your task

More stuff on data manipulation:

http://rpubs.com/ovolchenko/dataman

That’s all for today!