To visualise a model, it is very useful to be able to generate an
evenly spaced grid of points from the data. `data_grid`

helps you
do this by wrapping around `expand()`

.

1 |

`data` |
A data frame |

`...` |
Variables passed on to |

`.model` |
A model. If supplied, any predictors needed for the model
not present in |

`seq_range()`

for generating ranges from continuous
variables.

1 2 3 4 5 6 7 8 9 10 | ```
data_grid(mtcars, vs, am)
# For continuous variables, seq_range is useful
data_grid(mtcars, mpg = seq_range(mpg, 10))
# If you optionally supply a model, missing predictors will
# be filled in with typical values
mod <- lm(mpg ~ wt + cyl + vs, data = mtcars)
data_grid(mtcars, .model = mod)
data_grid(mtcars, cyl = seq_range(cyl, 9), .model = mod)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.