mr_inorder | R Documentation |
mr_inorder
and ms_inorder
use the order in which the
levels first appear in the data (which is invariant to locale),mr_inseq
and
ms_inseq
sort alphabetically (for the current locale). mr_infreq
sorts by frequency, and ms_inscore
applies a function to the values in each level – one such function is mean0
, which takes the mean of non-zero values. Finally, ms_reorder
and mr_reorder
use some function of a second variable computed on the observations where each level is present.
mr_inorder(x,...)
ms_inorder(x)
mr_inseq(x,...)
ms_inseq(x)
mr_infreq(x,na.rm=TRUE,...)
ms_infreq(x)
ms_inscore(x, fun=mean0)
mean0(y)
mr_reorder(x, v, fun=median,...)
ms_reorder(x, v, fun=median)
x |
|
na.rm |
Remove |
v , fun |
Sort levels of |
y |
numeric vector |
... |
not used |
Object of class mr
These are based on the reordering functions for factors in the
forcats
package.
data(ethnicity)
mr_infreq(ethnicity)
mr_inseq(ethnicity)
data(nzbirds)
mtable(nzbirds)
mtable(ms_inorder(nzbirds))
mtable(ms_inseq(nzbirds))
mtable(ms_inscore(nzbirds, mean0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.