createTestdata: Create testdata for clinical studies

Description Usage Arguments Value Examples

Description

Create testdata for clinical studies

Usage

1
2
createTestdata(strataVars, n = if (is.null(n.per.stratum)) 30 else NULL,
  n.per.stratum = NULL, format.patient = "P%03d", offset.patient = 0)

Arguments

strataVars

List of strata variables, each of which is defined in the form of a vector of possible (character) values.

n

Number of records to be created

n.per.stratum

optional. Vector of integer numbers defining the number of records for each possible stratum. The length of this vector must be equal to the number of possible strata (resulting from the product of lengths of vectors in strataVars)

format.patient

Passed as argument format to sprintf() when creating a unique id for each patient

offset.patient

integer number to be added to the generated patient numbers 1:n. Defaults to 0.

Value

Data frame with a column patient containing the patient's ID and one column for each stratum, named according to the element names in strataVars

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
strataVars <- list(
 sex = c("female", "male"),
 medication = c("yes", "no")
)

createTestdata(strataVars, n = 20)

# Define the number of patients in each stratum (there are four possible
# strata: length(strataVars$sex) * length(strataVars$medication))
createTestdata(strataVars, n.per.stratum = c(5, 6, 3, 4))

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