Description Usage Arguments Examples
Combines levels of a factor into new levels
1 | smashlevels(f, newlevels)
|
f |
factor. |
newlevels |
list. The names of |
1 2 3 4 5 6 7 8 | # create a factor with levels 30:60
age <- factor(sample(30:60, 200, replace=TRUE))
# combine 35-40 into a single level, 41-50 into a single level, and 51-60 into a single level
g <- smashlevels(age, list(`35-40` = 35:40, `41-50` = 41:50, `51-60` = 51:60))
table(g)
# If the syntax permits, the backticks can be avoided.
h <- smashlevels(age, list(young=30:34, pushing40 = 35:40, pushing50 = 41:50, fossilized = 51:120))
table(h)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.