R版本3.3.3(2015-08-14) - "消防安全"
我按照此链接(http://www.sthda.com/english/articles/print/12-ggplot2-dotplot-easy-dotplot-with-r-ggplot2-package/)的说明使用了ggplot2.dotplot。
我可以使用以下代码生成一个png文件:
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();
但是,当我将代码放在循环或函数中时。 png图像为空白。任何人都可以帮忙吗?非常感谢!
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();
}