R/data.R

Defines functions data_from_count

Documented in data_from_count

#' Data From Count
#' @description Creates a data vector with each label appearing the number of times specified in the count vector
#'
#' @param labels data labels (can be anytning)
#' @param count occurrences of each label
#'
#' @return
#' @export
#'
data_from_count <- function(labels, count) {
  if (length(labels) != length(count)) {
    NA
  } else {
    as.vector(unlist(sapply(1:length(labels),function(x) rep(labels[x], count[x]))))
  }
}
Emilostuff/dtuR documentation built on Dec. 17, 2021, 6:29 p.m.