Can't change a character to a factor? Error in `$<-.data.frame`(`*tmp*`, Week, value = integer(0)) : replacement has 'x' rows, data has 'y'

Viewed 26

I am trying to change a character to a factor using the code Data$Week<-as.factor(Data$Week)

It worked for the other components I was changing to a factor, but not for this one. This error appears:

Error in $<-.data.frame(*tmp*, Week, value = integer(0)) : replacement has 0 rows, data has 216

Why is this happenening?

0 Answers
Related