age nr.employed job marital education housing default emp.var.rate cons.price.idx cons.conf.idx
1 30 5099.1 blue-collar married basic.9y yes no -1.8 92.893 -46.2
2 39 5191.0 services single high.school no no 1.1 93.994 -36.4
3 25 5228.1 services married high.school yes no 1.4 94.465 -41.8
4 38 5228.1 services married basic.9y unknown no 1.4 94.465 -41.8
5 47 5195.8 admin. married university.degree yes no -0.1 93.200 -42.0
6 32 4963.6 services single university.degree no no -1.1 94.199 -37.5
7 32 4963.6 admin. single university.degree yes no -1.1 94.199 -37.5
8 41 5195.8 entrepreneur married university.degree yes unknown -0.1 93.200 -42.0
9 31 5195.8 services divorced professional.course no no -0.1 93.200 -42.0
10 35 5191.0 blue-collar married basic.9y no unknown 1.1 93.994 -36.4
Create the following variables:
cons.ratio
that is the ratio of cons.price.idx
on cons.conf.idx
. You can store the result in a vector called cons.ratio
in order to check whether your computation is correct.prev.nr.employed
containing the amount of employees in the previous quarter. You will need the variable emp.var.rate
for this which is the percentage change in nr.employed
compared to the previous quarter (i.e. -3.4 means that 3.4% of the employees from the previous quarter left). You can store the result in a vector called prev.nr.employed
in order to check whether your computation is correct.
Store the result with all the old variables and the two new variables in a data frame called survey_newvars
.