My data (TransDat70) contains 103 variables total. The first 102 are named "V1" through "V102", the last variable is names "Time.Min".
I need to generate 102 ggplots of each variable (V1 through V102) against the variable "Time.Min". I then need to save all these ggplots in a separate file (pdf) preferably all next to/below one another for comparison purposes.
I tried using code that I was able to find online but none has worked for me so far.
Here is my code:
var_list = combn(names(TransDat70)[1: 102], 2, simplify = FALSE)
plot_list = list()
for (i in 1: 3) {
p = ggplot(TransDat70, aes_string(x = var_list[[i]][1], y = var_list[[i]][2])) + geom_point()
plot_list[[i]] = p
}
for (i in 1: 3) {
plot70 = paste("iris_plot_", i, ".tiff", sep = "")
tiff(plot70)
print(plot_list[[i]])
dev.off()
}
pdf("plots.pdf")
for (i in 1: 3) {
print(plot_list[[i]])
}
dev.off()
Any suggestions?