Learn R Programming

randotools (version 0.2.4)

randolist_to_db: Reformat a randolist object to the requirements of a database

Description

Databases generally require a specific format to be able to import a randomization list. This function converts the randolist object to the format required by REDCap or secuTrial.

Usage

randolist_to_db(
  randolist,
  target_db = c("REDCap", "secuTrial"),
  strata_enc = NA,
  rando_enc = NA
)

Value

dataframe with columns required for import into target_db

Arguments

randolist

a randolist object from randolist or blockrand

target_db

the target database, either "REDCap" or "secuTrial"

strata_enc

a list of data frames with the encoding of each stratification variable. Should have two columns - the value used in randolist and code with the values used in the database. See the examples for details.

rando_enc

a data frame with the randomization encoding

Details

rando_enc should contain an arm column containing the values supplied to randolist, and a variable with the name required by the database with the values that map to those in arm. See the examples.

Examples

Run this code
r <- randolist(10,
               strata = list(sex = c("M", "F")),
               arms = c("T1", "T2"))
randolist_to_db(r,
  rando_enc = data.frame(arm = c("T1", "T2"),
                        rando_res = c(1, 2)),
  strata_enc = list(sex = data.frame(sex = c("M", "F"),
                                    code = 1:2)),
  target_db = "REDCap")
randolist_to_db(r,
  rando_enc = data.frame(arm = c("T1", "T2"),
                         rando_res = c(1, 2)),
  strata_enc = list(sex = data.frame(sex = c("M", "F"),
                                     code = 1:2)),
  target_db = "secuTrial")

Run the code above in your browser using DataLab