updateable.Rd
Creates a function wrapper that stores a call in the object returned by its
argument FUN
.
updateable(FUN, eval.args = NULL, Class)
get_call(x)
## updateable wrapper for mgcv::gamm and gamm4::gamm4
uGamm(formula, random = NULL, ..., lme4 = inherits(random, "formula"))
## updateable wrapper for MASS::fitdistr
fitdistr2(x, densfun, start, ...)
function to be modified, found via match.fun.
optionally a character vector of function arguments' names to be evaluated in the stored call. See ‘Details’.
optional character vector naming class(es) to be set onto the
result of FUN
(not possible if the result is an S4 object).
for get_call
, an object from which the call should be
extracted. For fitdistr2
, a numeric vector passed to
fitdistrMASS.
arguments to be passed to gamm
or gamm4
if TRUE
, gamm4
is called, gamm
otherwise.
Arguments passed to fitdistrMASS.
Arguments passed to respective wrapped functions.
Most model fitting functions in R return an object that can be updated or
re-fitted via update. This is possible thanks to the
function call stored in the object, which can be used (possibly modified)
later on. It is also used by dredge
to generate submodels. Some
functions (such as mgcv::gamm
or MCMCglmm::MCMCglmm
) do not
provide their result with the call
element. To work around this,
updateable
can be used on such a function to store the call. The
resulting “wrapper” should be used in exactly the same way as the
original function.
updateable
can also be used to repair an existing call
element,
e.g. if it contains dotted names that prevent re-evaluation
of a call.
The eval.args
argument specifies the names of the function arguments
to be evaluated in the stored call. This is useful if, for example, the
model object does not have a formula
element or does not
store the formula in any other way, and the modelling function has been
called with the formula specified as the variable name. In this case, the
default formula
method will try to retrieve the formula from the
stored call
, which does not guarantee that the variable will be
available at the time of retrieval, or that the value of that variable will
be the same as that used to fit the model (this is demonstrated in the
last ‘example’).
updateable
returns a function with the same arguments as FUN
,
wrapping a call to FUN
and adding an element named call
to its
result if possible, otherwise an attribute "call"
(if the returned
value is atomic or an S4 object).
get_call
is similar to getCall (defined in package
stats), but it can also extract the call
when it is an
attribute=attr (and not an element of the object). Because the
default getCall
method cannot do that, the default update
method
will not work with atomic or S4 objects resulting from updateable
wrappers.
uGamm
sets also an appropriate class onto the result ("gamm4"
and/or "gamm"
), which is needed for some generics defined in MuMIn
to work (note that unlike the functions created by updateable
it has no
formal arguments of the original function). As of version 1.9.2,
MuMIn::gamm
is no longer available.
update, getCall, getElement, attributes
gammmgcv, gamm4gamm4