mr_inorder {rimu}R Documentation

Reorder levels of multiple-response objects

Description

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.

Usage

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)

Arguments

x

mr

na.rm

Remove NA values before computing frequencies (NA sorts last)

v, fun

Sort levels of x according to the values of fun(v) for observations having each level

y

numeric vector

...

not used

Value

Object of class mr

References

These are based on the reordering functions for factors in the forcats package.

Examples

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))


[Package rimu version 0.6 Index]