Description Usage Arguments Details Value See Also Examples
Convert a continuous variable to a discrete variable.
1 2 3 4 5 6 7 8 9 10 |
x |
A numeric or integer vector. |
... |
Additional arguments passed to |
.m |
(optional) Default value for the 'm' parameter to |
.g |
(optional) Default value for the 'g' parameter to |
factorVars |
(optional) A character vector of variable names in |
skip |
(optional) A character vector of variable names in |
When x
is numeric, chop()
assumes that any specified values for cuts
,
g
, or m
are exactly as they are required to be in cut2()
. When x
is a
data frame, on the other hand, these parameters (and any other parameters passed to cut2()
or hist()
) are specified through parameters that have names which are common to the names of
numeric varibles in x
. (Any such specifications for non-numeric variables in x
are
ignored.) See examples for a demonstration of this usage. Note that .m
and .g
are
overridden by any explicit values given for specific variables. See behavior for variable 'drat'
in the final example.
A factor the same length as x
.
hist
and Hmisc::cut2
for more details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | table(chop(0:100))
table(chop(0:100000))
table(chop(0:100, breaks = c(-Inf,23,68,Inf))) #breaks passed to hist()
table(chop(0:100, cuts = c(-Inf,23,68,Inf))) #same result, but cuts is passed to cut2()
table(chop(0:100, g=4))
table(chop(0:100, m=17))
summary(chop(mtcars, .m=10, .factorVars = c("cyl","vs","am","gear")))
z <- chop(mtcars,
.factorVars = c("cyl","vs","am","gear"),
.skip = c("mpg"),
.g = 4,
drat = list(g=8),
qsec = list(cuts=c(0,16,18,20,100)))
summary(z)
table(z$drat)
g_chop <- chop(glucose, glucose = list(cuts = c(0,109,125,300)))
table(g_chop$glucose, g_chop$cohort)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.