Hi,
I have this simple df:
source <- data.frame(
stringsAsFactors = FALSE,
URN = c("21GB0421520600348376",
"21GB0418447730308396","21GB0424598350378907","21GB0418447730308382","21GB0420497680334731",
"21GB0416416410294317","21GB0424598350378906",
"21GB0412336390238885","21GB0424594550377080",
"21GB0418447730308379","21GB0414375210263918","21GB0424594550377079",
"21GB0414375210263920","21GB0418452110311403",
"21GB0423572270366131"),
QF0 = c(2, 6, 33, 35, 32, 4, 33, 1, 32, 64, 2, 64, 2, 8, 33)
)
..where QF0 should be recoded into seven variables with the following logic:
Values and new variables' names:
1 - Routine service / maintenance
2 - Repair
4 - Recall campaign
8 - Tire change
16 - Windscreen, windows, other work related to glass
32 - MOT related visit
64 - Other
Other values are combinations of the above:
The first df record has value 2 therefore values for all these 7 new variables should be:
0 for Routine service / maintenance
1 for Repair
0 for Recall campaign
0 for Tire change
0 for Windscreen, windows, other work related to glass
0 for MOT related visit
0 for Other
The second df record has value 6 (2+4) therefore values for all these 7 new variables should be:
0 for Routine service / maintenance
1 for Repair
1 for Recall campaign
0 for Tire change
0 for Windscreen, windows, other work related to glass
0 for MOT related visit
0 for Other
The third df record has value 33 (32+1) therefore values for all these 7 new variables should be:
1 for Routine service / maintenance
0 for Repair
0 for Recall campaign
0 for Tire change
0 for Windscreen, windows, other work related to glass
1 for MOT related visit
0 for Other
I can do this recoding easily in Excel but is it possible doing this in R?
Once the coging is complete, is it possible to create one multiple response variable in R like in other statistical packages? This variable could be used for all tabulations.