mr_lump | R Documentation |
Combine the least common or most common levels of a mr
object into an "other" level.
mr_lump(x, n, prop, other_level = "Other", ties.method = c("min", "average", "first", "last", "random", "max"),...)
x |
Object of class |
n |
Positive integer to keep the most common |
prop |
Positive prop preserves values that appear at least prop of the time. Negative prop preserves values that appear at most -prop of the time. |
other_level |
Label for the lumped levels |
ties.method |
How to handle ties. Passed to |
... |
not used |
An object of class mr
Based on fct_lump
from the forcats
package.
data(ethnicity) mtable(ethnicity) mtable(mr_lump(ethnicity,2)) mtable(mr_lump(ethnicity,-2)) data(rstudiosurvey) ## Other software being used other_software<- as.mr(rstudiosurvey[[40]]) mtable(other_software) ## The top 20 responses common<-mr_lump(other_software, n=20) mtable(common) ## 'None' isn't really another package mtable(mr_drop(common,"None")) ## Packages with at least 20% use mtable(mr_lump(other_software, prop=0.2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.