Skip to content

Instantly share code, notes, and snippets.

@dgrtwo
Created June 4, 2018 15:45
Show Gist options
  • Save dgrtwo/fbe4d9ba2c701712cd14a3938f22caa8 to your computer and use it in GitHub Desktop.
Save dgrtwo/fbe4d9ba2c701712cd14a3938f22caa8 to your computer and use it in GitHub Desktop.
library(modelr)
library(tidyverse)
library(broom)
mtcars %>%
crossv_kfold(k = 10) %>%
mutate(model = map(train, ~ lm(mpg ~ wt, .)),
result = map2(model, test, ~ augment(.x, newdata = .y))) %>%
unnest(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment