makePatterns | R Documentation |
This function concatenates the columns of a matrix or data frame for each row into a single character variable, which can optionally be reconverted to numeric. It is typically called internally by sorter
. For example, a row of a matrix containing c(1, 2, 3, 5)
will be concatenated into "1235"
.
makePatterns(dat, times = NULL, num = TRUE, mindur = NULL, igrpt = FALSE)
dat |
A matrix or data frame such as |
times |
See |
num |
Logical indicator, specifying whether a numeric version of the concatenated rows should be returned. When |
mindur |
Minimum duration. If |
igrpt |
Option to ignore repeated values when sorting, allowing the sorting algorithm in |
A vector of patterns of length nrow(dat)
.
Stephen J. 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
sorter
for further processing of patterns.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.