split_mixed_datasets {EDCimport}R Documentation

Split mixed datasets

Description

Split mixed tables, i.e. tables that hold both long data (N values per patient) and short data (one value per patient, duplicated on N lines), into one long table and one short table.

Usage

split_mixed_datasets(
  datasets = get_datasets(),
  id = get_key_cols()$patient_id,
  ...,
  ignore_cols = getOption("edc_cols_crfname", "CRFNAME"),
  output_code = FALSE,
  verbose = TRUE
)

Arguments

datasets

a dataframe or a list of dataframes to split. Default to all the datasets from .lookup.

id

the patient identifier, probably "SUBJID". Should be shared by all datasets. Case-insensitive.

...

not used

ignore_cols

columns to ignore when considering a table as long. Default to getOption("edc_cols_crfname", "CRFNAME"). Case-insensitive.

output_code

whether to print the code to explicitly write. Can also be a file path.

verbose

whether to print informations about the process.

Value

a list of the new long and short tables. Use load_list() to load them into the global environment.

Examples

#tm = read_trialmaster("filename.zip", pw="xx")
tm = edc_example_mixed()
names(tm)
#load_list(tm)
print(tm$long_mixed) #`val1` and `val2` are long but `val3` is short

mixed_data = split_mixed_datasets(tm, id="subjid", verbose=TRUE)
load_list(mixed_data)
print(long_mixed_short) 
print(long_mixed_long) 

#alternatively, get the code and only use the datasets you need
split_mixed_datasets(tm, id="SUBJID", output_code=TRUE)
filename = tempfile("mixed_code", fileext=".R")
split_mixed_datasets(tm, id="SUBJID", output_code=filename)
readLines(filename)

[Package EDCimport version 0.4.1 Index]