Description Usage Arguments Value Author(s) References See Also Examples
View source: R/longCatEDA_0.31.r
Function to create objects of class longCat
.
1 2 
y 
a data matrix or data frame of numeric states in wide (as opposed to long) format with cases in rows and repeated observations in columns. It is reccomended that 
times 
The If If When The 
Labels 
a vector of numeric or character labels for the response options in 
tLabels 
numeric or character labels for the time points in 
id 
An optional variable identifying or naming the rows of 
events 
An event 
event.times 
A The 
eventLabels 
If 
longCat
returns an object of class longCat
which is a list containing at least the following components:
y 

y.sorted 

dim 
the dimension of 
times 
the 
endt 
the 
times.sorted 
if 
endt.sorted 

labels 
the 
tLabels 
the 
factors 
a vector containing the unique values in 
IndTime 
a logical indicator of whether 
nfactors 
the number of unique values in 
sorted 
a logical indicator of whether 
ascending 
logical indicator. If 
group 
a vector of the same length as the number of rows in 
groupLabels 
a optional vector of character or numeric labels for the 
order.y 
A matrix with identification (see input 
events 
A matrix of events. 
event.times 
A matrix of event times. 
eventLabels 
A vector of event labels. 
Stephen Tueller
Tueller, S. J., Van Dorn, R. A., & Bobashev, G. V. (2016). Visualization of categorical longitudinal and times series data (Report No. MR00331602). Research Triangle Park, NC: RTI Press. http://www.rti.org/publication/visualizationcategoricallongitudinalandtimesseriesdata
longCatPlot
to plot longCat
objects created by the longCat
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64  # create the longcat object similar to Figure 2 in Tueller (2016)
times < c(1,100,200,300,400,500,600)
f2lc < longCat(example2cat, times)
# object summary
summary(f2lc)
# compare growth curves to longCat
par(mfrow=c(1,2), bg='cornsilk3')
longContPlot(example2cat, times, ylim=c(1,5),
main='Growth Curves', ylab='', xlab='Days')
longCatPlot(f2lc, lwd=4, main='Horizontal Line Plot', colScheme='heat', legendBuffer=.2)
par(mfrow=c(1,1), bg='transparent')
# illustrate individually varying times of observation
set.seed(642531)
y < matrix(sample(1:5, 500, replace=TRUE), 100, 5)
set.seed(963854)
times < matrix(runif(600, 1, 3), 100, 6)
# times must be cumulative
times < t(apply(times, 1, cumsum))
lc < longCat(y, times=times)
par(mfrow=c(1,1), bg='cornsilk3', mar=c(5.1, 4.1, 4.1, 10.1), xpd=TRUE)
cols < longCatPlot(lc, legendBuffer=0, groupBuffer=0,
main='Individually Varying Times of Observation')
legend(15.5, 100, legend=lc$Labels, lty=1, col=cols, lwd=2)
par(bg='transparent', mar = c(5, 4, 4, 2) + 0.1, xpd=FALSE)
# illustrate the adding event indicators
set.seed(45962)
events < matrix(sample(1:3, 200, replace=TRUE), 100, 2)
set.seed(23498)
event.times < matrix(sample(c(times), 200, replace=FALSE), 100, 2)
labels < c('Street', 'Drug Tx', 'Jail', 'Prison', 'Unknown')
eventLabels=c('Arrest', 'Drug Test', 'Hearing')
lc < longCat(y, times=times, Labels=labels,
events=events, event.times=event.times,
eventLabels=eventLabels)
par(mfrow=c(1,1), bg='cornsilk3', mar=c(5.1, 4.1, 4.1, 12.1), xpd=TRUE)
cols < longCatPlot(lc, legendBuffer=0, groupBuffer=0,
main='Superimpose Events Over States')
legend(15.5, 100, legend=lc$Labels, lty=1, col=cols, lwd=2)
legend(15.5, 40, legend=lc$eventLabels, pch=1:length(lc$eventLabels))
par(bg='transparent', mar = c(5, 4, 4, 2) + 0.1, xpd=FALSE)
## Not run:
# illustrate handling non timeordered input (e.g., factor analysis data)
y < matrix(sample(c('1', '2', '3', '4', '5'), 500, replace=TRUE), 100, 5)
lc < longCat(y)
par(mfrow=c(1,1), bg='cornsilk3', mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE)
cols < longCatPlot(lc, legendBuffer=0)
legend(6, 100, legend=lc$factors, lty=1, col=cols, lwd=2)
par(bg='transparent', mar = c(5, 4, 4, 2) + 0.1, xpd=FALSE)
# illustrate plotting with more than 9 categories
# (a warning is issued)
y < matrix(sample(1:18, 500, replace=TRUE), 100, 5)
lc < longCat(y)
par(mfrow=c(1,1), bg='cornsilk3', mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE)
cols < longCatPlot(lc, legendBuffer=0)
legend(6, 100, legend=lc$factors, lty=1, col=cols, lwd=2)
par(bg='transparent', mar = c(5, 4, 4, 2) + 0.1, xpd=FALSE)
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.