Created
March 8, 2018 22:22
-
-
Save jackbrookes/3bbcc47cdd246b3d8a9173a4b9bacf43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gridExtra) | |
plot_cars_var <- function(col_name){ | |
ggplot(mtcars, aes_string(x = "mpg", y = col_name)) + | |
geom_smooth() + | |
geom_point() | |
} | |
mtcars %>% | |
dplyr::select(-mpg, everything()) %>% | |
colnames() %>% | |
purrr::map(plot_cars_var) %>% | |
grid.arrange(grobs = ., ncol = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the extra example. I ran 2 ways and the gather function ended up being quicker: