Learn R Programming

longCatEDA (version 0.13)

longCat: Creation of Objects of Class longCat

Description

Function to create objects of class longCat.

Usage

longCat(y, times = NULL, Labels = NULL, tLabels = NULL, id = NULL)

Arguments

y
a data matrix or data frame in wide (as opposed to long) format with cases in rows and repeated observations in columns. At most, y can have 9 unique non-missing values.
times
time points used for the x-axis in plotting. Either a vector of the same length as the number of columns in y (i.e., all cases have the same times of observation), or a matrix of the same dimension as y (i.e., individually varyin
Labels
a vector of numeric or character labels for the response options in y. Must be the same length as the number of unique non-missing values in y. Default is NULL and is assigned the values 1:max(unique(y))
tLabels
numeric or character labels for the time points in times. Default is NULL and is assigned the values 1:ncol(y).
id
A optional variable identifying or naming the rows of y. Returned as the first column of the matrix order.data (see order.data in the value section below).

Value

  • longCat returns an object of class longCat which is a list containing at least the following components:
  • datay
  • data.sortedy sorted (default is NULL unless sorter has been applied to the longCat object).
  • dimthe dimension of data.
  • timesthe times object as described above.
  • times.sortedif times is a matrix of the same dimension as y, times.sorted contains a matrix of individually varying times of observation with the same sorting as data.sorted.
  • labelsthe labels vector as described above
  • tLabelsthe tLabels vector as described above
  • factorsa vector containing the unique values in data. Not that if the unique values in y were not sequential integers starting at 1, both factors and data are recoded such that they contain sequential integers starting at 1.
  • IndTimea logical indicator of whether times is a matrix of the same dimension as data. If TRUE, longCatPlot treats these times as individually varying times of observation.
  • nfactorsthe number of unique values in data, and is the same as the length of the factors vector. nfactors is determined by longCat, but cannot exceed 9. If users have data with more than 9 categories, continuous plotting methods are recommended (e.g., try longContPlot.)
  • sorteda logical indicator of whether data has been sorted by the sorter function. If TRUE, data.sorted (and times.sorted if IndTime is TRUE) will not be NULL.
  • ascendinglogical indicator. If sorted is TRUE, this will indicate whether sorting was done ascending. (default is NULL unless sorter has been applied to the longCat object).
  • groupa vector of the same length as the number of rows in data (default is NULL unless sorter has been applied to the longCat object along with a grouping variable).
  • groupLabelsa optional vector of character or numeric labels for the group variable (see sorter).
  • order.dataA matrix with identification (see input id above) and sorting information. Rows of the matrix correspond to rows of y and the columns are id, and order variable, and a variable representing the unique data patterns in y. The former is returned only if id is provided to longCat. The latter two are only returned by {sorter}. If only unique data patterns are desired, use makePatterns; see example(makePatterns).

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

longCatPlot to plot longCat objects created by the longCat function.

Examples

Run this code
# create the longcat object for Figure 2 in Tueller (2011)
times <- c(1,100,200,300,400,500)
f2lc <- longCat(example2cat, times)
# see the object
summary(f2lc)
# plot the continuous and categogorical versions of this data
par(mfrow=c(1,2), bg='antiquewhite3')
longContPlot(example2cat, times, ylim=c(1,5), main='A', ylab='', xlab='Day')
longCatPlot(f2lc, lwd=4, main='B', colScheme='heat')
par(mfrow=c(1,1), bg='white')

Run the code above in your browser using DataLab