R/preproc.R

Defines functions preproc_regu

preproc_regu <- function(regu = "2_1_0.5") {
  if (is.logical(regu)) {
    if (!regu) {
      return(c(0, 0, 0))
    }
    if (regu) {
      return(c(1, 1 / 2, 1 / 4))
    }
  }
  if (is.character(regu)) {
    regu <- as.numeric(strsplit(regu, "_")[[1]])
  }
  if (is.numeric(regu) & length(regu) == 1) {
    regu <- c(regu, regu / 2, regu / 4)
  }
  stopifnot(is.numeric(regu))
  stopifnot(length(regu) == 3)
  stopifnot(all(regu >= 0))
  return(regu)
}

Try the cases package in your browser

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

cases documentation built on April 3, 2025, 9:24 p.m.