View source: R/filter.infrequent.R
filter.infrequent | R Documentation |
Function for grouping infrequent levels into a dummy level.
filter.infrequent(x, threshold = 5, dummy = "OTHER")
x |
a factor or character vector. |
threshold |
numeric. Any levels having fewer observations than this will be grouped into the dummy level. |
dummy |
character string specifying name of the dummy level. |
Function for lumping infrequent levels into a dummy level. Useful for sorting out rare observations.
Jason Grafmiller
data("brown_genitives")
## table of the number of observations per text
sort(table(brown_genitives$Text))
## table of the number of observations per text, for
## only those texts with more than 20 observations
sort(table(filter.infrequent(brown_genitives$Text, 20)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.