This function will take a data frame in R and write it out to csv. It also creates a metadata folder, storing the xpt file along with other useful information.
The csv and spec-list.yml are always written. The xpt and define document are only regenerated when the csv or spec-list.yml content has changed, avoiding unnecessary diffs in version control from embedded timestamps.
Diffs are always computed against the baseline (SVN or local) and reported in diff-summary.txt whenever at least one data or spec diff exists.
If a legacy metadata folder containing diffs.csv is detected, it is automatically removed and regenerated.
write_derived(
.data,
.spec,
.file,
.subject_col = "ID",
.prev_file = NULL,
.compare_from_svn = TRUE,
.return_base_compare = FALSE,
.execute_diffs = TRUE
)a data frame
a yspec object
csv file name to write out to (including path)
subject column name (defaults to ID)
csv file name of previous version (defaults to .file)
logical. Should the data comparison be done on the latest svn version? (If not, local version is used)
logical. Should the two current and previous versions of the datasets be returned?
logical. Should the diffs be executed?
if (FALSE) { # \dontrun{
nm_spec <- yspec::ys_load(system.file("derived", "pk.yml", package = "mrgda"))
nm <- readr::read_csv(system.file("derived", "pk.csv", package = "mrgda"), na = ".")
write_derived(.data = nm, .spec = nm_spec, .file = "data/derived/pk.csv")
} # }