Skip to content

Instantly share code, notes, and snippets.

@malcolmbarrett
Created August 17, 2018 02:08
Show Gist options
  • Save malcolmbarrett/6510d11de340b9b1e87a74f1fcfaa4ae to your computer and use it in GitHub Desktop.
Save malcolmbarrett/6510d11de340b9b1e87a74f1fcfaa4ae to your computer and use it in GitHub Desktop.
library(tidyverse)
mtcars %>%
select(starts_with("c")) %>%
summarise_all(mean)
mega_lm <- function(var) {
fmla <- as.formula(paste("mpg ~", var))
lm(fmla, data = mtcars) %>%
tidy()
}
# purrr
map_dfr(c("hp", "cyl"), mega_lm, .id = "model")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment