# update.formula

##### Model Updating

`update.formula`

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

- Keywords
- models

##### Usage

```
## S3 method for class 'formula':
update(old, new, \dots)
```

##### 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

Either or both of `old`

and `new`

can be objects such as
length-one character vectors which can be coerced to a formula via
`as.formula`

.

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 occurrence
of `new`

, and substitutes
the *rhs* of the `old`

formula for any occurrence
of `new`

. The result is then
simplified *via* `terms.formula(simplify = TRUE)`

.

##### Value

- The updated formula is returned. The environment of the result is
that of
`old`

.

##### See Also

##### Examples

`library(stats)`

```
update(y ~ x, ~ . + x2) #> y ~ x + x2
update(y ~ x, log(.) ~ . ) #> log(y) ~ x
update(. ~ u+v, res ~ . ) #> res ~ u + v
```

*Documentation reproduced from package stats, version 3.3, License: Part of R 3.3*

### Community examples

Looks like there are no examples yet.