Learn R Programming

longCatEDA (version 0.13)

sorter: General Sorting Function

Description

A function to sort an longCat object created by longCat. sorter must be used directly when stratified plots of subgroups is desired, or when sorting other than the default sorting is desired. Otherwise, sorter is used internally with the defaults by longCatPlot if lc$sorted=FALSE.

Usage

sorter(lc, ascending = TRUE, whichColumns = NULL, num = TRUE,
                 mindur = NULL, igrpt = FALSE, customSort = NULL,
                 initFirst = FALSE, group = NULL, groupLabels = NULL,
                 ggap = 10)

Arguments

lc
an object of class longCat created by longCat.
ascending
logical - should sorting be done ascending. Default is TRUE.
whichColumns
a numeric list indicating which columns in lc$data should be used for sorting (.e.g., c(1, 5, 7)). Useful if, for example, an intervention occurs after data collection has started, and the user is not interested in sorting on pre
num
mindur
igrpt
should sorter (ig)nore (r)e(p)ea(t)ed values for each row in lc$data for sorting purposes? See norpt.
customSort
a vector of the same length as the number of rows in lc$data providing a user defined variable on which to sort the data prior to secondarily applying the default sort. If group is not NULL, group will be sorted on p
initFirst
if customSort is not NULL, setting initFirst=TRUE will sort on initial values prior to the custom sorting variable.
group
a vector of the same length as the number of rows in lc$data indicating group membership. Default is NULL. If group is NA, corresponding rows in lc$data will be deleted prior to completing t
groupLabels
a vector of numeric or character labels of the same length as the number of unique values in group. Default is NULL. If group is not NULL and groupLabels is not provided, then the numeric va
ggap
a number zero or greater. The number blank rows to be plotted between groups when group is specified. As the number of rows in lc$

Value

  • Returns an object of class longCat where lc$sorted=TRUE. See longCat for values.

References

Tueller, S. J., Van Dorn, R. A., and Bobashev, G. V. (2013). Visualization of Categorical Longitudinal and Times Series Data. Manuscript Under Review.

See Also

longCat and longCatPlot.

Examples

Run this code
# sort with a grouping variable and plot
par(mfrow=c(1,1), bg='lightblue')
times <- c(1,100,200,300,400,500)
grouplc <- longCat(example3, times)
group <- sample(1:3, nrow(example3), replace=TRUE)
grouplc <- sorter(grouplc, group=group)
longCatPlot(grouplc, main='Grouped Data', colScheme='heat', lwd=2)
par(mfrow=c(1,1), bg='white')

Run the code above in your browser using DataLab