【发布时间】:2015-02-02 06:52:59
【问题描述】:
在为绘图微调参数时,我想将所有测试运行保存在不同的文件中,这样它们就不会丢失。到目前为止,我设法使用下面的代码来做到这一点:
# Save the plot as WMF file - using random numbers to avoid overwriting
number <- sample(1:20,1)
filename <- paste("dummy", number, sep="-")
fullname <- paste(filename, ".wmf", sep="")
# Next line actually creates the file
dev.copy(win.metafile, fullname)
dev.off() # Turn off the device
这段代码有效,生成名称为“dummy-XX.wmf”的文件,其中 XX 是 1 到 20 之间的随机数,但看起来很麻烦,一点也不优雅。
有没有更优雅的方法来完成同样的事情?甚至,要计算代码运行了多少次并为文件生成漂亮的渐进式数字?
【问题讨论】: