named list giving the numeric values for the levels of the named
factor. For factors not in the list, default numeric levels are
used, as described in
fac2num.factor.
coerce
logical value for whether to coerce non numeric levels to integers.
VALUE:
A
data.frame with the same names columns as
df and factors
replaced by numeric variables.
SIDE EFFECTS:
The class of the returned dataframe is simply
data.frame, regardless
of the class of
df.
SEE ALSO:
.
EXAMPLES:
df1 <- data.frame(A = ordered(rep(c("hi", "low"), 5)),
B = factor(rep(c("-","+"), rep(5, 2))),
x = rnorm(10))
df2 <- fac2num(df1)
df2 <- fac2num(df1, num = list(A = c(10,0),
B = c(20,10)))