I was wondering if someone could help me get this code to return multiple graphs. I would like each graph to be labelled "plot_i" (plot_G1, plot_G2). I am at a loss as to how to get my function to return this. Any help would be appreciated!
library(lubridate)
library(tidyverse)
#Dummy Data Frame
DateTime <- c("1999/01/01 11:00","1999/01/02 11:00","1999/01/03 11:00","1999/01/01 11:00","1999/01/02 11:00","1999/01/03 11:00","1999/01/01 11:00","1999/01/02 11:00","1999/01/03 11:00")
Step <- c("Condition1","Condition1","Condition1","Condition2","Condition2","Condition2","Condition3","Condition3","Condition3")
G1 <- runif(9)
G2 <- runif(9)
G3 <- runif(9)
G4 <- runif(9)
test_df <- data.frame(DateTime = DateTime, Step = Step, G1 = G1, G2 = G2, G3 = G3, G4 = G4)
test_df$DateTime.lub <- ymd_hm(test_df$DateTime)
test_df
#Want to create a function that will provide graphs for every G1, G2, G3 and G4 and return them!
list <- colnames(test_df)
list <- list[-c(1,2,7)]
list
#test plot - works
ggplot(data = test_df, aes(x= DateTime.lub, y = G1))+
geom_line(aes(size = Step))
#Function does not return graph
for (i in list){
ggplot(data = test_df, aes(x= DateTime.lub, y = i))+
geom_line(aes(colour = Step))
}