ys_extend: Extend a yspec object

View source: R/extend.R

ys_extendR Documentation

Extend a yspec object

Description

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

Usage

ys_extend(x, file = ys_extend_file(x), silent = FALSE)

Arguments

x

A yspec object (the primary spec).

file

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.

silent

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.

Details

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.

Examples

extension_file <- system.file("spec", "nm-extension.yml", package = "yspec")

spec <- ys_help$spec() 
spec2 <- ys_extend(spec, extension_file)
tail(spec2)

ys_extend(spec)

## Not run: 
# 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")   

## End(Not run)


metrumresearchgroup/yspec documentation built on May 24, 2024, 12:48 a.m.