It feels ridiculous that I can't figure this out, but I can't. I have a list of numbers that I need to replace with characters. So for instance, I need to replace all values of 1 with the corresponding item name that the 1 represents, the 2s with the second item, and so on. I have tried to use the replace function, but it's not doing the trick. Can someone please offer guidance? Thanks!
Do you mean you want to replace
"1" or something else?
Can you provide a reproducible example?
Thank you. I need to replace 1 with a corresponding category.
data <- c(5, "NA", 3, 2,6)
I need to replace the values in the vector with their corresponding category names. So I need to replace all 5s, for instance, with "50 < = x < 59", and all 3s with "30 < = y < 39". But it is a long list, and it isn't convenient to go through one by one, especially because I need a generalizable solution. So I want to do the equivalent of "find and replace" but none of the R functions I have tried are working.
Is it something that you already have somewhere? Could you just use some sort of join, then mutate based on that?
Mutate worked! Thank you so much!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.