I'm trying to save several plots in R using for loops. Each plot can be obtained from the following lines of code and then I can save the plots individually:
mod_8_heatmap <- make_module_heatmap(module_name = "ME8")
mod_8_heatmap
I tried the following loop to save more plots:
> for (i in 7:10){
+ mod_i_heatmap <- make_module_heatmap(module_name = paste("ME", i, sep = ""))
+
+ mod_i_heatmap
+ jpeg(paste("ME", i, ".jpeg", sep = ""))
+ mod_i_heatmap
+ dev.off()
+ }
Even though the files are created in the directory, they are blank. I tried this code as well but got the following error:
> for (i in 7:20){
+ mod_i_heatmap <- make_module_heatmap(module_name = paste("ME", i, sep = ""))
+
+ jpeg(mod_i_heatmap, file=paste("ME", i, ".jpeg", sep = ""))
+ mod_i_heatmap
+ dev.off()
+ }
Error in switch(units, `in` = res, cm = res/2.54, mm = res/25.4, px = 1) * :
non-numeric argument to binary operator
Can you let me know what I'm doing wrong?