Don’t get suckered when converting factors! Numeric data can be assigned to a factor type which will throw a wrench in a plot or analysis (1/3)
A knee jerk reaction would be to convert it to a numeric with as.numeric()
. That doesn’t work either. (2/3)
However if you use as.numeric(as.character())
then it works. That’s because factors are ordinal and named so if you convert the type to character first to ensure R is working with the factor names instead of the ranks. (3/3)