Is there a function in R that takes a column of nominal variables (more than two) and assigns a numeric value. The values in the column are unknown, however I can give you a taste of what they are. Alternatively, I was considering deleting this column however the dataset "Occupation" could be a handy column to keep. Need to do this so I can process the table using "Gowers" method. Data I am analysing come from here
> [1] w q q w w m
>
Levels: aa c cc d e ff i j k m q r w x
Hopefully I've explained that well and cheers in advance for looking at my question
This is code I used it in the end for Occupation re-scaling between 0 and 1, hope this can be of use to someone else. Not 100% certain this is the correct labels but at least give you a guide on changing "factor" levels in R.
Data$Occupation <- factor(Data$Occupation,
levels = c("aa", "c", "cc", "d", "e", "ff", "i", "j", "k", "m", "q", "r", "w", "x"),
labels = c(0, 0.07692307692307692308, 0.08333333333333333333, 0.09090909090909090909,
0.1, 0.11111111111111111111, 0.125, 0.14285714285714285714,
0.16666666666666666667, 0.2, 0.25, 0.33333333333333333333, 0.5, 1))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.