View source: R/utils-simdata-car.R
car_pb | R Documentation |
Generate permuted block treatment assignments
car_pb(z, trt_label, trt_alc, blocksize = 4L)
z |
The car_strata design matrix, as a data frame with factor variables |
trt_label |
Treatment label |
trt_alc |
Treatment allocation vector |
blocksize |
Permuted block blocksize |
A vector of treatment assignments with labels from the 'trt_label' argument, based on stratified permuted block randomization.
# Create car_strata variables
library(fastDummies)
library(dplyr)
x <- runif(100)
z <- cut(x, breaks=c(0, 0.25, 0.5, 0.75, 1.0))
z <- dummy_cols(z) %>%
mutate(across(where(is.numeric), as.factor))
car_pb(z[, 2:5], c(0, 1, 2), trt_alc=c(1/4, 1/2, 1/4), blocksize=4L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.