ransch | R Documentation |
Generate block randomization schedule tables with fixed or random block sizes.
ransch(n, block, arms, r = rep_len(1L, length(arms)), strata = NULL)
ranschtbl(
n,
block,
arms,
r = rep_len(1L, length(arms)),
strata = NULL,
write = NULL
)
## S3 method for class 'ransch'
summary(x, totals = TRUE, verbose = TRUE, ...)
n |
sample size of study or each stratum |
block |
block size; note if for randomly-sized blocks, a vector of potential block sizes; note that
a block size must be a multiple of |
arms |
names of the treatment arms |
r |
randomization ratio; see examples |
strata |
an optional named list of vectors for each stratum |
write |
a file path to write a directory with csv files for each randomization table |
## no strata, 2-3 treatments with varying randomization ratios
ransch(24, 4, 1:2) ## 1:1
ransch(24, 6, 1:3) ## 1:1:1
ransch(24, 8, 1:3, c(1, 2, 1)) ## 1:2:1
## randomly-sized blocks
ransch(24, c(2, 4, 6), 1:2)
set.seed(1)
r1 <- ransch(24, c(3, 6, 9), 1:3)
set.seed(1)
r2 <- ransch(24, 1:10, 1:3)
## note that these two are the same since only blocks sized 3, 6, 9
## work for 1:1:1 randomization
identical(r1, r2)
addmargins(table(r1[[1]][, -1]))
summary(r1)
## one two-level stratum
ransch(24, 4, 1:2, strata = list(Age = c('<65', '>=65')))
## multiple strata
strata <- list(Site = LETTERS[1:3], Age = c('<65', '>=65'))
r3 <- ransch(24, 4, 1:2, strata = strata)
summary(r3)
## tables for printing
ranschtbl(24, 4, c('Pbo', 'Trt'))
ranschtbl(24, 4, c('Pbo', 'Trt'), c(1, 3), strata)
## Not run:
## use a path to write tables to file (one csv per stratum)
ranschtbl(24, 4, c('Pbo', 'Trt'), strata = strata, write = '~/desktop')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.