update(object, ...) update(object, formula, ..., evaluate=T, class)
call
, which is the expression used to create itself
(with no abbreviations for argument names).
.
on either side of the ~ gets replaced by the left or right side of the formula in
object
. The dot on the left can be omitted. By default, it refits
object
using the same formula as in
object
.
object$call
, can be removed by putting nothing on the right side of the
=
.
For example, the argument
x=,
in a call to
update()
causes the
x
argument, if present in
object$call
, to be removed.
TRUE
(the default), the new call is evaluated; otherwise, the call is returned as an unevaluated expression.
lm()
,
aov()
,
glm()
, etc.
This argument allows the model to be switched from one kind to another,
assuming the formula and other arguments make sense for the new model.
Although suggestive,
class
is a slight misnomer since the object may already inherit from this new class.
update
is a generic function.
Do
methods("update")
to see a list of
currently-defined methods.
Not all methods support the
evaluate
and
class
arguments.
update
works by extracting
the call contained
in the old object, modifying it, and evaluating the modified call.
update
does
not use any part of the old object except for its call
(as a general rule; some methods may differ).
So, for example,
if you have added attributes to the object after it was created,
they will not be included in the new result.
Also, the old object is not changed, unless you overwrite it
with the new result.
update
does not support objects whose
calls contain abbreviations for argument names.
Typically
object
is created by a
function that calls either
sys.call()
or
match.call()
to create the call;
the latter is preferable for
update
because it expands abbreviated argument names.
fit <- lm(Fuel ~ Weight + Disp., data = fuel.frame) # refit, unchanged update(fit) # refit, adding term update(fit, ~ . + Type) # transform response to log scale; drop intercept update(fit, log(.) ~ . -1) # use all the 2nd order interactions of original fit update(fit, ~ .^2) # supply a subset update(fit, subset=Weight > 2600) # Remove an argument, prevent evaluation (would fail) update(fit, data =, evaluate=F)