Selected numeric variables are grouped into factors with ranges selected from the data.
numtocat.syn(data, numtocat = NULL, print.flag = TRUE, cont.na = NULL,
catgroups = 5, style.groups = "quantile")
A list with the following components:
a data frame with the numeric variables replaced by factors grouped into ranges.
a named list of the breaks used to divide each numeric variable into categories.
a named list of the levels for the categories of each numeric variable.
a data frame with the original numeric data.
a named list of the levels for the categorical version of each numeric variable.
names of the variables changed to categories.
positions in data of the variables changed to categories.
a data frame.
a vector of numbers or variable names of numeric variables
to be grouped into factors. If NULL
all the numeric variables in data
will be grouped.
if TRUE a list of grouped variables is printed.
a named list that gives the values of the named variables to be
treated as separate categories, often missing values like -8
. See the
corresponding parameter of syn()
.
a single integer or a vector of integers indicating the target
number of groups for the variables in numtocat in the same order as numtocat,
or as their relative postions in data. The achieved number of groups may be
different if, for example there are fewer than ngroups
distinct values.
parameter of the function classInt()
that determines
how the breaks used to categorise each variable are chosen. See the help file
for classInt()
for details. The default setting "quantile"
makes
groups of approximately equal size. To divide into approximately equal ranges
we suggest using "fisher"
.
SD2011.cat <- numtocat.syn(SD2011, cont.na = list(income = -8 , unempdur = -8,
nofriend = -8))
summary(SD2011.cat$data)
Run the code above in your browser using DataLab