0

I am trying to revalue the column score in my dataset. After I check the Min, 1st Qua, 3rd Quad and Max. I try to Label specific range as following code

data2019$Score <-revalue(data2019$Score,c
("(2.853,4.553]" = "Not Happy", "(4.553,6.187]" = "Happy", "(6.187,7.769]" = "Flourishing"))

I keep getting error that x is not a factor or a character vector. Please be advised on this issue

  • Please provide a reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). You can try `dplyr::recode` instead. – Ronak Shah Dec 06 '20 at 05:42
  • @RonakShah Since I have Score column with the smallest value is 2.853 to the largest value of 7.769. I divide into 3 different range and assign each range from low medium and high. in my case as Not Happy, Happy and Flourishing. I "(2.853,4.553]" = "Not Happy" "(4.553,6.187]" = "Happy" "(6.187,7.769]" = "Flourishing" – Lan Nguyen Dec 06 '20 at 05:50

1 Answers1

0

Try using cut with labels instead.

data2019$Group <- cut(data2019$Score, 3, 
                      labels = c("Not Happy", "Happy", "Flourishing"))
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213