Use this function to read and join another spec file to an existing
yspec
object. The additional spec file can contain additional columns
that might be added to the data set on an ad-hoc basis or could include
modeling outputs (e.g. IPRED
).
ys_extend(x, file = ys_extend_file(x), silent = FALSE)
A yspec
object (the primary spec).
The path to a yaml specification file to load and join to x
;
if file
is not passed, the yspec
object will be searched for the
extend_file
attribute in SETUP__:
and will fail if it is not found.
Logical; if TRUE
, issue message reporting the number of
columns added via extension; the user will alternatively be warned if there
were no columns added.
The extension is accomplished using ys_join()
, so any columns in the
extension spec that already exist in the primary spec are dropped. Use
ys_select()
on the the primary spec to drop columns that might be in the
extension and that you want to retain in the result.
If there are no new columns added by extension, that indicates all columns in the extension spec already exist in primary spec. In this case, a warning will be generated.
extension_file <- system.file("spec", "nm-extension.yml", package = "yspec")
spec <- ys_help$spec()
spec2 <- ys_extend(spec, extension_file)
#> Note: added 4 columns by extension.
tail(spec2)
#> name info unit short source
#> 24 LDOS --- mg last dose amount .
#> 25 MDV -d- . MDV ysdb_internal
#> 26 BLQ -d- . below limit of quantification .
#> 27 PHASE --- . study phase indicator .
#> 28 STUDY -d- . study number .
#> 29 RF cd- . renal function stage .
#> 30 PRED --e . population prediction nm-extension
#> 31 IPRED --e . individual prediction nm-extension
#> 32 WRES --e . weighted residual nm-extension
#> 33 CWRES --e . conditional weighted residual nm-extension
ys_extend(spec)
#> Note: added 5 columns by extension.
#> name info unit short source
#> C cd- . comment character ysdb_internal
#> NUM --- . record number ysdb_internal
#> ID --- . subject identifier ysdb_internal
#> SUBJ c-- . subject identifier ysdb_internal
#> TIME --- hour TIME look
#> SEQ -d- . SEQ .
#> CMT --- . compartment number ysdb_internal
#> EVID -d- . event ID ysdb_internal
#> AMT --- mg dose amount ysdb_internal
#> DV --- micrograms/L dependent variable ysdb_internal
#> AGE --- years age ysdb_internal
#> WT --- kg weight ysdb_internal
#> CRCL --- ml/min CRCL .
#> ALB --- g/dL albumin ysdb_internal
#> BMI --- m2/kg BMI ysdb_internal
#> AAG --- mg/dL alpha-1-acid glycoprotein .
#> SCR --- mg/dL serum creatinine .
#> AST --- . aspartate aminotransferase .
#> ALT --- . alanine aminotransferase .
#> HT --- cm height ysdb_internal
#> CP -d- . Child-Pugh score look
#> TAFD --- hours time after first dose .
#> TAD --- hours time after dose .
#> LDOS --- mg last dose amount .
#> MDV -d- . MDV ysdb_internal
#> BLQ -d- . below limit of quantification .
#> PHASE --- . study phase indicator .
#> STUDY -d- . study number .
#> RF cd- . renal function stage .
#> WRES --e . weighted residuals analysis1-ext
#> CWRES --e . conditional weighted residuals analysis1-ext
#> IPRED --e . individual prediction analysis1-ext
#> PRED --e . population prediction analysis1-ext
#> LDV --e . log DV analysis1-ext
if (FALSE) { # \dontrun{
# In case COL is in both the primary spec and the extension, but you want
# to retain what is in the extension
spec %>% select(-COL) %>% ys_extend("extension.yml")
} # }