Skip to contents

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.

Usage

mighty_study(path, populate = FALSE)

Arguments

path

character(1) path to a directory containing YAML metadata files.

populate

logical(1) if TRUE, calls populate_core() then populate_sparse() before returning. Default is FALSE.

Value

A mighty_study S7 object extending list:

List elements

mighty_domain objects, named by their id field. Access via e.g. study$adsl.

@study

Study-level properties from _study.yml, or empty list if no properties file exists.

@mighty

Mighty framework configuration from _mighty.yml, or empty list if no configuration file exists.

@path

The source directory path as character(1).

Details

The function scans the directory for files matching *.yaml or *.yml:

  • Files named _study.yml or _study.yaml are treated as study properties

  • Files named _mighty.yml or _mighty.yaml are treated as mighty framework config

  • All other YAML files are loaded as mighty_domain objects

  • Only one _mighty.yml and one _study.yml file 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)