#' All the Possible SQS's
#'
#' @param catvec Vector of the different categories found in the sequences.
#' @param k Maximum length of sequence silhouette.
#'
#' @return Matrix containing all the possible SQS for this sequence's elements.
#' @export
#'
#' @examples
#' AllSQS(c('A','B','C'),2)
AllSQS <- function(catvec, k) {
k <- k - 1
# seqlist <- seqlist[sapply(seqlist, function(x) x[1, 1]) != 0]
# x <- as.vector(unique(unlist(lapply(seqlist, function(x) {
# return(x[, 2])
# }))))
x <- as.vector(catvec)
sqspossible <- matrix(NA, length(x) + k * length(x)^2, 3)
sqspossible[1:length(x), ] <- as.matrix(t(sapply(x, function(y) {
return(c(y, y, "0"))
})))
j <- length(x) + 1
for (i in 1:(k)) {
sqspossible[j:(j + length(x)^2 - 1), ] <- cbind(gtools::permutations(n = length(x), r = 2, v = x, repeats.allowed = T), rep(i, length(x)^2))
j <- j + length(x)^2
}
return(as.matrix(sqspossible))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.