Convert factors to numbers
If you have a vector of factors it is easy to get the factor level; however, I always forget how to extract the factor value. I ran into the answer here.
__ x x [1] 1.61 1.12 1.26 0.09 -0.13 0.16 -0.03 -0.1 0.09 -0.47 [11] A B Levels: -0.03 0.09 -0.1 -0.13 0.16 -0.47 1.12 1.26 1.61 A B__ as.numeric(x) [1] 9 7 8 2 4 5 1 3 2 6 10 11 NA__ ... [Read more...]