Recode numeric values in R

前端 未结 3 450
一向
一向 2021-01-12 18:09

I want to recode some numeric values into different numeric values and have had a go using the following code:

survey$KY27PHYc <- revalue(survey$KY27PHY1, c

3条回答
  •  一个人的身影
    2021-01-12 18:47

    This function does not work on numeric vector. If you want to use it, you can do as follows:

     x <- 1:10 # your numeric vector
    
     as.numeric(revalue(as.character(x), c("2" = "33", "4" = "88")))
    
     # [1]  1 33  3 88  5  6  7  8  9 10
    

提交回复
热议问题