Convert Factor to Vector in R
Surprisingly, there is no built-in command to convert a factor into a vector in R.
The following line will do the trick:
outputVector = as.numeric(levels(inputFactor)[as.integer(inputFactor)]
Written by Dionysios Barmpoutis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#R
Authors
Related Tags
#r
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#