createRandomSequences: Create random sequences of blockwise equally distributed...

Description Usage Arguments Value Examples

Description

Create random sequences of blockwise equally distributed values. The blocksizes are chosen according to the number of values to be created.

Usage

1
createRandomSequences(x, counts, names.strata = NULL)

Arguments

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

Value

list of vectors of values out of x with lengths according to the values given in counts

Examples

 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

hsonne/blockrand2 documentation built on May 17, 2019, 6:16 p.m.