Convert Factors to Numeric Variables
DESCRIPTION:
Convert factors in a data structure to numeric vectors.
This function is an S Version 3 generic (see Methods);
method functions can be written to handle specific
S Version 3 classes of data. Classes which already
have methods for this function include:
factor
data.frame
USAGE:
fac2num(x, ...)
fac2num.default(x, ...)
REQUIRED ARGUMENTS:
- x
-
An S object.
VALUE:
Returns
x
unchanged if
is.numeric(x)
is TRUE. Otherwise generates
an error.
EXAMPLES:
df1 <- data.frame(ordered(rep(c("hi", "low"), 10)),
factor(rep(c("+","-"), rep(2,5))), x = rnorm(10))
df2 <- fac2num(df1)