Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

group_sort

Sort split by grouping predictor.


Description

Function uses sort.list to return indices of of a vector, sorted per group.

Usage

group_sort(x, group = NULL, decreasing = FALSE)

Arguments

x

A vector to be sorted.

group

A names list that specify the different groups to split the data.

decreasing

Logical: whether or not the sort order should be decreasing.

Value

Indices indicating the order of vector x per group.

Author(s)

Jacolien van Rij

See Also

Examples

# example InsectSprays from R datasets
InsectSprays$Type <- ifelse(InsectSprays$spray %in% c('A','B', 'F'), 1, 2)

ind <- group_sort(InsectSprays$count, 
    group=list(Spray=InsectSprays$spray, Type=InsectSprays$Type))
InsectSprays[ind,]
InsectSprays

plotfunctions

Various Functions to Facilitate Visualization of Data and Analysis

v1.4
GPL (>= 2)
Authors
Jacolien van Rij [aut, cre]
Initial release
2020-04-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.