makeFactor {cdparcoord} | R Documentation |
Change numeric variables factors.
Description
Change numeric variables that are specified in varnames
to factors so that discretize
won't partition.
Usage
makeFactor(df, varnames)
Arguments
df |
Input data frame. |
varnames |
Names of variables to be converted to factors. |
Author(s)
Norm Matloff <matloff@cs.ucdavis.edu>, Vincent Yang <vinyang@ucdavis.edu>, and Harrison Nguyen <hhnguy@ucdavis.edu>
Examples
data(prgeng)
pe <- prgeng[,c(1,3,5,7:9)]
class(pe$educ) # integer
pe <- makeFactor(pe,c('educ','occ','sex'))
class(pe$educ) # factor
# nice to give levels names
levels(pe$sex) <- c('male','female')
head(pe$sex)
[Package cdparcoord version 1.0.1 Index]