R version 3.3.3 (2015-08-14) -- "Fire Safety"
I was using ggplot2.dotplot following the instructions from this link (http://www.sthda.com/english/articles/print/12-ggplot2-dotplot-easy-dotplot-with-r-ggplot2-package/).
I could generate a png file just fine using the following code:
install.packages("devtools")
library(devtools)
install_github("easyGgplot2", "kassambara")
library(easyGgplot2)
png(filename = "test.png", width = 250, height = 300);
df <- ToothGrowth
ggplot2.dotplot(data=df, xName='dose',yName='len',
mainTitle="Plot of length according\n to the dose",
xtitle="Dose (mg)", ytitle="Length")
dev.off();
However, when I put the code in a loop or in a function. The png image is blank. Could anyone help with it? Thanks a lot!
for (i in 1:1) {
png(filename = "test.png", width = 250, height = 300);
df <- ToothGrowth
ggplot2.dotplot(data=df, xName='dose',yName='len',
mainTitle="Plot of length according\n to the dose",
xtitle="Dose (mg)", ytitle="Length")
dev.off();
}