# an input data matrix storing discrete states for tips (in rows) X four characters (in columns)
data1 <- matrix(c(0,rep(1,3),rep(0,2)), ncol=1)
data2 <- matrix(c(rep(0,4),rep(1,2)), ncol=1)
data3 <- matrix(c(1,rep(0,3),rep(1,2)), ncol=1)
data <- cbind(data1, data2, data1, data3)
colnames(data) <- c("C1", "C2", "C3", "C4")
data
# determine the duplicated patterns from inut data matrix
res <- dcDuplicated(data, pattern.wise="column")
## return an integer vector
res
## get index for unique patterns
ind <- sort(unique(res))
## As seen above, the returned integer vector tells there are 3 unique patterns:
## they are in columns (1, 2, 4). The column 3 is duplicated from column 1.
Run the code above in your browser using DataLab