R/elaborator_calculate_pattern_number.R

Defines functions elaborator_calculate_pattern_number

Documented in elaborator_calculate_pattern_number

#' Pattern number for input patterns defined by decreases, stability and increases
#'
#' @description
#' This function is mostly useful for generating the qualitative trend analysis plots. It returns the pattern numbers for input patterns.
#'
#'@param p matrix with patterns within each row. A pattern is described by a combination of elements -1, 0, 1 for decrease, stability and increase between adjacent visits.
#'
#'@return A numeric vector giving the pattern numbers for all input patterns.
#'
#'@keywords internal

elaborator_calculate_pattern_number <- function(p) {
  . <- NULL
  as.vector((as.matrix(p + 1) %*% as.matrix(3^(0:(dim(p)[2] - 1)))))
}

Try the elaborator package in your browser

Any scripts or data that you put into this service are public.

elaborator documentation built on Feb. 23, 2021, 1:06 a.m.