Variable labels are important for understanding the contents of a variable. secuTrialR offers two main methods to get those labels. labels_secuTrial returns a named list of labels. label_secuTrial adds labels and units to variables (and data.frames) which can then be queried via label or units.

labels_secuTrial(object, form = NULL)

label_secuTrial(object, ...)

label(x)

units(x)

label(x) <- value

units(x) <- value

Arguments

object

a secuTrialdata object

form

which form (string)

...

further parameters

x

any object

value

any object

Value

labels_secuTrial returns a named vector label_secuTrial returns the same object as object, but with labels added to variables and data.frames label and units return strings with the appropriate labels

secuTrialdata object with labels applied to each variable

Details

For labels_secuTrial, regular expressions are used with form (specifically, it is inserted between ( and )$ to identify the form). Consequently, if form matches multiple forms (because the beginning is different), multiple forms may be returned. You could be more specific with the regular expression, remembering that it is inserted between ( and )$.

Note

The label_secuTrial/label syntax is similar to that used in Hmisc, with the advantage that it does not change data types (Hmisc coerces everything to labelled integer). Similar to Hmisc, however, most operations will remove the labels.

Examples

# APPROACH 1: labels_secuTrial
# ex. 1
# prepare path to example export
export_location <- system.file("extdata", "sT_exports", "BMD",
                               "s_export_CSV-xls_BMD_short_en_utf8.zip",
                               package = "secuTrialR")
# load all export data
sT_export <- read_secuTrial_raw(data_dir = export_location)
# get all labels
labels <- labels_secuTrial(sT_export)
labels[["age"]]
#> [1] "Age"

# ex. 2
# load export
sT_export <- read_secuTrial_raw(system.file("extdata", "sT_exports", "lnames",
                                            "s_export_CSV-xls_CTU05_long_miss_en_utf8.zip",
                                            package = "secuTrialR"))

# get labels for sae, treatment and surgeries forms
labels <- labels_secuTrial(sT_export, form = c("sae", "treatment", "surgeries"))


# APPROACH 2: label_secuTrial
# load secuTrial export with separate reference table
sT_export <- read_secuTrial_raw(system.file("extdata", "sT_exports", "lnames",
                                            "s_export_CSV-xls_CTU05_long_ref_miss_en_utf8.zip",
                                            package = "secuTrialR"))
# label the secuTrialdata object
sT_export_labelled <- label_secuTrial(sT_export)
# form label
label(sT_export_labelled$ctu05baseline)
#> [1] "General screen"
# variable label
label(sT_export_labelled$ctu05baseline$visit_date)
#> [1] "Date of visit"
# sampling units
units(sT_export_labelled$ctu05baseline$height)
#> [1] "cm"