I am using a for loop to create 100 ggplots in R to be graphed onto one sheet of paper. However, I keep getting a mapping must be created by aes() error and I am not sure how to fix it.
I have tried the get
function with and without environments, unclear where to go next.
for(i in 1:99){
nam <- paste("p", i, sep = "")
otunam <- paste("OTU", i, sep = "")
otunam1 <- get(otunam, envir = as.environment(histotu), inherits = TRUE)
plot <- ggplot(histotu, aes(x=otunam)) + geom_histogram(histotu, stat = "bin", binwidth = 0.01) + geom_vline(xintercept=expD[1,i], color = "red") + xlab(otunam)
assign(nam, plot)
}
I would like to clear this error and be able to make 100 graphs using grid.arrange. I have this part to work, but not the for loop to create the objects that it calls.