Concatenate Multivariate Data into Numeric or Character Patterns
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"
.
makePatterns(dat, times, num = TRUE, mindur = NULL, igrpt = FALSE)
dat |
a matrix or data frame such as |
times |
see |
num |
logical indicator, should a numeric version of the concatenate rows be return. Default is |
mindur |
minimum duration. If |
igrpt |
Option to ignore repeated values when sorting, allowing the sorting algorithm in |
out |
A vector of patterns of length |
.
Stephen Tueller
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
# 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 ) )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.