R/02-dictionaries_functions.R
as_data_dict_mlstr.Rd
Validates the input object as a valid data dictionary compliant with formats
used in Maelstrom Research ecosystem, including Opal, and returns it with
the appropriate madshapR::class
attribute. This function mainly helps
validate input within other functions of the package but could be used to
check if an object is valid for use in a function.
as_data_dict_mlstr(object, as_data_dict = FALSE, name_standard = FALSE)
A potential valid data dictionary to be coerced.
Whether the input data dictionary should not be coerced with specific format restrictions for compatibility with other Maelstrom Research software. FALSE by default.
Whether the input data dictionary has variable names compatible with Maelstrom Research ecosystem, including Opal)or not. FALSE by default.
A list of data frame(s) with madshapR::class
'data_dict_mlstr'.
A data dictionary contains the list of variables in a dataset and metadata
about the variables and can be associated with a dataset. A data dictionary
object is a list of data frame(s) named 'Variables' (required) and
'Categories' (if any). To be usable in any function, the data frame
'Variables' must contain at least the name
column, with all unique and
non-missing entries, and the data frame 'Categories' must contain at least
the variable
and name
columns, with unique combination of
variable
and name
.
The object may be specifically formatted to be compatible with additional Maelstrom Research software, in particular Opal environments.
For a better assessment, please use data_dict_evaluate()
.
{
# use madshapR_DEMO provided by the package
data_dict <- madshapR_DEMO$data_dict_MELBOURNE
as_data_dict_mlstr(madshapR_DEMO$data_dict_MELBOURNE)
}
#> $Variables
#> # A tibble: 6 × 6
#> name `label:en` valueType index `description:en` unit
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 id id text 1 id of the participant NA
#> 2 Gender Gender integer 2 Gender NA
#> 3 BMI BMI decimal 3 Body Mass Index kg/m…
#> 4 age age integer 4 Age of Participant years
#> 5 smo_status smo_status integer 5 Whether the participant is a curr… NA
#> 6 prg_curr prg_curr integer 6 Are you currently pregnant ? NA
#>
#> $Categories
#> # A tibble: 12 × 4
#> variable name `label:en` missing
#> <chr> <chr> <chr> <lgl>
#> 1 Gender 1 Male FALSE
#> 2 Gender 2 Female FALSE
#> 3 age -888 don't want to answer TRUE
#> 4 smo_status 1 never smoked FALSE
#> 5 smo_status 2 current smoker FALSE
#> 6 smo_status 3 former smoker FALSE
#> 7 smo_status -77 don't want to answer TRUE
#> 8 prg_curr 0 not currently pregnant FALSE
#> 9 prg_curr 1 currently pregnant FALSE
#> 10 prg_curr 8 Don’t want to answer TRUE
#> 11 prg_curr 9 Don’t know TRUE
#> 12 prg_curr -77 not applicable TRUE
#>
#> attr(,"madshapR::class")
#> [1] "data_dict_mlstr"