This always annoys me and i have to look it up all the time, when i try to convert a factor to a numeric, the values change to rank values. #damn
So to transform a factor f to it's approximately original numeric values and no "bull shit" ranks. This command below will save you.
as.numeric(levels(f))
Also mentioned that this is recommended and slightly more efficient than
as.numeric(as.character(f))
Now backed up, bring on any other disturbing factors.
as.numeric(levels(f))
Also mentioned that this is recommended and slightly more efficient than
as.numeric(as.character(f))
Now backed up, bring on any other disturbing factors.
No comments:
Post a Comment
Add any comments if it helped :)