Recoding variables with R

后端 未结 5 685
长情又很酷
长情又很酷 2020-11-28 04:36

Recoding variables in R, seems to be my biggest headache. What functions, packages, processes do you use to ensure the best result?

I\'ve found very few useful exam

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 05:36

    I found mapvalues from plyr package very handy. Package also contains function revalue which is similar to car:::recode.

    The following example will "recode"

    > mapvalues(letters, from = c("r", "o", "m", "a", "n"), to = c("R", "O", "M", "A", "N"))
     [1] "A" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "M" "N" "O" "p" "q" "R" "s" "t" "u" "v" "w" "x" "y" "z"
    

提交回复
热议问题