tidyverse / modelr

Helper functions for modelling
https://modelr.tidyverse.org
GNU General Public License v3.0
401 stars 65 forks source link

Add stand evaluation version data_grid() #40

Closed jrnold closed 6 years ago

jrnold commented 7 years ago

This adds data_grid_ as a standard evalution version of the NSE function data_grid.

A use case for this is looping over different predictors in a model to calculate changes holding everything else constant:

mod <- lm(mpg ~ wt + cyl + vs, data = mtcars)
## currently
for (i in c("wt", "cyl", "vs")) {
  data_grid_(mtcars, eval(quote(i)), .model = mod)
}

# with data_grid_
for (i in c("wt", "cyl", "vs")) {
  data_grid_(mtcars, i, .model = mod)
}
hadley commented 6 years ago

This should now just work via pass through to tidyeval in tidyr. Let me know if you need help converting your lazyeval solution to tidy eval.