I have a column that’s a factor variable. I need to change the value of all cells where the factor is a certain rarely occurring level. I’m using the following code but it doesn’t seem to be working:
test2$timeFactor <- ifelse(test2$timeFactor == '94', '-1000', test2$timeFactor)
I’ve also tried:
test2$timeFactor <- factor(ifelse(test2$timeFactor == '94', '-1000', test2$timeFactor))
but neither seems to work. Anything obvious I’m missing here?
You are better off changing the
levels: