update.formula             package:stats             R Documentation

Model Updating

Description:

     'update.formula' is used to update model formulae. This typically
     involves adding or dropping terms, but updates can be more
     general.

Usage:

     ## S3 method for class 'formula':
     update(old, new, ...)

Arguments:

     old: a model formula to be updated.

     new: a formula giving a template which specifies how to update.

     ...: further arguments passed to or from other methods.

Details:

     The function works by first identifying the _left-hand side_ and
     _right-hand side_ of the 'old' formula. It then examines the 'new'
     formula and substitutes the _lhs_ of the 'old' formula for any
     occurence of "'.'" on the left of 'new', and substitutes the _rhs_
     of the 'old' formula for any occurence of "'.'" on the right of
     'new'.

Value:

     The updated formula is returned.

See Also:

     'terms', 'model.matrix'.

Examples:

     update(y ~ x,    ~ . + x2) #> y ~ x + x2
     update(y ~ x, log(.) ~ . ) #> log(y) ~ x

