Learn R Programming

longCatEDA (version 0.13)

makePatterns: Concatenate Multivariate Data into Numeric or Character Patterns

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

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

Arguments

dat
a matrix or data frame such as lc$data 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 differe
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 data corresponding to cells in
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$data. Default is FALSE. See

Value

  • outA vector of patterns of length nrow(dat)
  • .

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

sorter

Examples

Run this code
# 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 ) )

Run the code above in your browser using DataLab