Description Usage Arguments Value Examples
Create random sequences of blockwise equally distributed values. The blocksizes are chosen according to the number of values to be created.
1 | createRandomSequences(x, counts, names.strata = NULL)
|
x |
vector of values to be chosen from |
counts |
vector of integers defining the lengths of vectors of values to be created |
names.strata |
vector of character to be used as element names in the output list |
list of vectors of values out of x
with lengths according to
the values given in counts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Define stratum levels
strata <- list(
sex = c("male", "female"),
medication = c("yes", "no"),
lesion = c("low", "high")
)
# Create some testdata using the stratum levels and group and count by stratum
byStratum <- stratify(createTestdata(strata, 50))
# Create random sequences of treatments (A, B)
sequences <- createRandomSequences(
x = c("A", "B"),
counts = byStratum$n,
names.strata = byStratum$stratum
)
# Append a column "treatments" showing the sequences of treatments as comma
# separated lists
byStratum$treatments <- sapply(sequences, paste, collapse = ",")
# Show the result
byStratum
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.