makeFactor: Change numeric variables factors.

Description Usage Arguments Author(s) Examples

View source: R/discretize.R View source: R/utils.R

Description

Change numeric variables that are specified in varnames to factors so that discretize won't partition.

Usage

1
    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

1
2
3
4
5
6
7
8
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)

matloff/cdparcoord documentation built on Aug. 5, 2019, 3:50 p.m.