Creates a mighty_study object by loading all YAML metadata files from a
directory. Each YAML file (except _mighty.yml and _study.yml) is parsed
as a mighty_domain object. The optional _study.yml file provides
study-level properties and the optional _mighty.yml file provides
mighty framework configuration.
Arguments
- path
character(1)path to a directory containing YAML metadata files.- populate
logical(1)ifTRUE, callspopulate_core()thenpopulate_sparse()before returning. Default isFALSE.
Value
A mighty_study S7 object extending list:
- List elements
mighty_domain objects, named by their
idfield. Access via e.g.study$adsl.@studyStudy-level properties from
_study.yml, or empty list if no properties file exists.@mightyMighty framework configuration from
_mighty.yml, or empty list if no configuration file exists.@pathThe source directory path as
character(1).
Details
The function scans the directory for files matching *.yaml or *.yml:
Files named
_study.ymlor_study.yamlare treated as study propertiesFiles named
_mighty.ymlor_mighty.yamlare treated as mighty framework configAll other YAML files are loaded as mighty_domain objects
Only one
_mighty.ymland one_study.ymlfile is allowed per directory
Write Study Metadata
Use write_config() to serialize a mighty_study() object back to YAML
files. Each domain is written as a separate file, plus
_mighty.yml and _study.yml when non-empty.
If path is NULL (default), files are written to x@path.
Examples
# Load example study
study <- mighty_study(
path = system.file("examples", package = "mighty.metadata")
)
# List tables with metadata
names(study)
#> [1] "ADAE" "ADSL" "ADVS"
# Access ADVS
study$ADVS
#> <mighty.metadata::mighty_domain>
#> ADVS: Vital Signs Analysis Dataset
#> Class: BASIC DATA STRUCTURE
#> Keys: USUBJID, PARAMCD, and AVISITN
# Access study-level properties
study@study
#> $study_id
#> [1] "example_study"
#>
# Access mighty framework configuration
study@mighty
#> $external_data
#> $external_data[[1]]
#> $external_data[[1]]$id
#> [1] "DM"
#>
#> $external_data[[1]]$keys
#> [1] "STUDYID" "USUBJID"
#>
#>
#> $external_data[[2]]
#> $external_data[[2]]$id
#> [1] "VS"
#>
#> $external_data[[2]]$keys
#> [1] "STUDYID" "USUBJID"
#>
#>
#> $external_data[[3]]
#> $external_data[[3]]$id
#> [1] "AE"
#>
#> $external_data[[3]]$keys
#> [1] "STUDYID" "USUBJID"
#>
#>
#>
# Load and populate in one step
study <- mighty_study(
path = system.file("examples", package = "mighty.metadata"),
populate = TRUE
)
# Write study back to YAML
tmp <- tempdir()
write_config(study, path = tmp)
