Enhance Formula by Wrapping each Term, e.g., by "s(.)"
Enhance Formula by Wrapping each Term, e.g., by "s(.)"
The main motivation for this function has been the easy construction of a full GAM formula from something as simple as Y ~ ..
The potential use is slightly more general.
wrapFormula(f, data, wrapString ="s(*)")
Arguments
f: the initial formula; typically something like Y ~ ..
data: data.frame to which the formula applies; see, formula or also gam or lm.
wrapString: character string, containing "*", specifying the wrapping expression to use.
Returns
a formula very similar to f; just replacing each additive term by its wrapped version.
Note
There are limits for this to work correctly; notably the right hand side of the formula f should not be nested or otherwise complicated, rather typically just . as in the examples.