% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mighty_study.R, R/y_write_config.R
\name{mighty_study}
\alias{mighty_study}
\title{Mighty Study}
\usage{
mighty_study(path, populate = FALSE)
}
\arguments{
\item{path}{\code{character(1)} path to a directory containing YAML metadata files.}

\item{populate}{\code{logical(1)} if \code{TRUE}, calls \code{\link[=populate_core]{populate_core()}} then
\code{\link[=populate_sparse]{populate_sparse()}} before returning. Default is \code{FALSE}.}
}
\value{
A \code{mighty_study} S7 object extending \code{list}:
\describe{
\item{List elements}{\link{mighty_domain} objects, named by their \code{id} field.
Access via e.g. \code{study$adsl}.}
\item{\verb{@study}}{Study-level properties from \verb{_study.yml}, or empty list
if no properties file exists.}
\item{\verb{@mighty}}{Mighty framework configuration from \verb{_mighty.yml}, or empty list
if no configuration file exists.}
\item{\verb{@path}}{The source directory path as \code{character(1)}.}
}
}
\description{
Creates a \code{mighty_study} object by loading all YAML metadata files from a
directory. Each YAML file (except \verb{_mighty.yml} and \verb{_study.yml}) is parsed
as a \link{mighty_domain} object. The optional \verb{_study.yml} file provides
study-level properties and the optional \verb{_mighty.yml} file provides
mighty framework configuration.
}
\details{
The function scans the directory for files matching \verb{*.yaml} or \verb{*.yml}:
\itemize{
\item Files named \verb{_study.yml} or \verb{_study.yaml} are treated as study properties
\item Files named \verb{_mighty.yml} or \verb{_mighty.yaml} are treated as mighty framework config
\item All other YAML files are loaded as \link{mighty_domain} objects
\item Only one \verb{_mighty.yml} and one \verb{_study.yml} file is allowed per directory
}
}
\section{Write Study Metadata}{

Use \code{write_config()} to serialize a \code{mighty_study()} object back to YAML
files. Each domain is written as a separate file, plus
\verb{_mighty.yml} and \verb{_study.yml} when non-empty.

If \code{path} is \code{NULL} (default), files are written to \code{x@path}.
}

\examples{
# Load example study
study <- mighty_study(
  path = system.file("examples", package = "mighty.metadata")
)

# List tables with metadata
names(study)

# Access ADVS
study$ADVS

# Access study-level properties
study@study

# Access mighty framework configuration
study@mighty

# 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)

}
\seealso{
\link{mighty_domain}, \code{\link[=write_config]{write_config()}}, \code{\link[=populate_sparse]{populate_sparse()}},
\code{\link[=populate_core]{populate_core()}}, \code{\link[=create_md_col]{create_md_col()}}
}
