Learn R Programming

itsadug (version 2.0)

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.

See Also

sort.list

Other Utility functions: convertNonAlphanumeric, diff_terms, findAbsMin, find_difference, find_n_neighbors, getDec, getRange, list2str, missing_est, move_n_point, print_summary, se, summary_data, timeBins

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