R/completeRand.R

Defines functions completeRand

Documented in completeRand

# random assignment vectors according to complete randomization

completeRand <- function(w, nrand) {
  # formatting
  if (sum(factor(w) == w) > 0) w <- data.matrix(w)
  if (ncol(w) == 1) w <- as.vector(w)
  # random assignments
  if (is.vector(w)) {
    lapply(1:nrand, function(i) sample(w))
  } else {
    lapply(1:nrand, function(i) w[sample(length(w[, 1])), ])
  }
}

Try the randomizationInference package in your browser

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

randomizationInference documentation built on May 18, 2022, 1:06 a.m.