Learn R Programming

itsadug (version 0.8)

group_sort: Utility function.

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.

See Also

sort.list

Other Data utility functions: findAbsMin; find_n_neighbors; move_n_point; print_summary; summary_data

Examples

Run this code
data(simdat)
range(simdat$Y)
ind <- group_sort(simdat$Y,
    group=list(Group=simdat$Group, Trial=simdat$Trial))
head(simdat[ind,])

Run the code above in your browser using DataLab