After creating a plot matrix using GGally::ggpairs(), I would like to store the individual scatter plots for later use.
Here is my current code:
# load necessary package
library(GGally) # loads `ggplot2`
library(magrittr) # allows for the use of `%>%`
# create a matrix of plots
mtcars %>%
na.omit() %>%
ggpairs(columns = 1:7)
# how do I automate this process?
P1 <- ggplot(aes(x = disp, y = hp)) +
geom_point()
P2 <- ggplot(aes(x = drat, y = hp)) +
geom_point()
P3 <- ggplot(aes(x = hp, y = qsec)) +
geom_point()
I'm getting an error that says the data must be a dataframe. I tried to specify the data from the na.omit() pipe using a . but I received the same result.
Any advice is appreciated!
