makePatterns: Concatenate Multivariate Data into Numeric or Character...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/longCatEDA_0.31.r

Description

Function to concatenate the columns of a matrix or data frame for each row into a single character variable, which can optionally be reconverted to numeric. Called internally by sorter. For example, a row of a matrix containing c(1, 2, 3, 5) will be concatenated to "1235".

Usage

1
makePatterns(dat, times, num = TRUE, mindur = NULL, igrpt = FALSE)

Arguments

dat

a matrix or data frame such as lc$y from an longCat object created by longCat.

times

see times in longCat.

num

logical indicator, should a numeric version of the concatenate rows be return. Default is TRUE. When num=TRUE, the return is rescaled by moving a decimal point between the first and second digits. This ensures that, under different numbers of observations or missing data, ordering is not unduly impacted by patterns of missing data. Users are encouraged to try sorting with num=TRUE and num=FALSE when experimenting to find the sorting that leads to the clearest plot. When lc$sorted=FALSE and there is no missing data in lc$y and lc$IntTime=FALSE, longCatPlot will change num to FALSE.

mindur

minimum duration. If times is a matrix or data frame of individually varying times of observation of the same dimension as dat, selecting mindur > 0 results in all cells in y corresponding to cells in times - times[,1] < mindur being changed to NA (where times - times[,1] changes the times from a matrix of observed times to a matrix of durations for each state in dat). This minimizes the effect of short durations on the sorting algorithm in sorter. Default is NULL.

igrpt

Option to ignore repeated values when sorting, allowing the sorting algorithm in sorter to smooth over regions of no change for each row in lc$y. Default is FALSE. See norpt.

Value

out

A vector of patterns of length nrow(dat)

.

Author(s)

Stephen Tueller

References

Tueller, S. J., Van Dorn, R. A., & Bobashev, G. V. (2016). Visualization of categorical longitudinal and times series data (Report No. MR-0033-1602). Research Triangle Park, NC: RTI Press. http://www.rti.org/publication/visualization-categorical-longitudinal-and-times-series-data

See Also

sorter

Examples

1
2
3
4
5
6
7
8
9
# create an arbitrary matrix and demonstrate
temp <- matrix( sample(1:9, 40, replace=TRUE), 10, 4)
print(temp)
makePatterns(temp, num=FALSE)

# examine the unique patterns of data
bindat <- matrix( sample(0:1, 500, replace=TRUE), 100, 5)
uniquePatterns <- makePatterns( bindat, num=FALSE)
as.matrix( table( uniquePatterns ) )

longCatEDA documentation built on May 29, 2017, 9:26 p.m.