0

创建一些图表,并希望创建日期/时间在文件名中。我发现这个问题的答案对该主题非常有帮助,并且

 paste("plotname",Sys.time(),".wmf",sep='')

事实上吐出来

[1] "plotname2013-07-02 11:55:04.wmf"

win.metafile(paste("plotname",Sys.time(),".wmf",sep=''))
# win.metafile("test.wmf")
ggplot(data.file, aes(x = group, y = delta)) + geom_boxplot()
dev.off()

Error in win.metafile(paste("plotname", Sys.time(), ".wmf", sep = "")) : unable to start win.metafile:plotname2013-07-02 11:56:23.wmf() device

它与更简单的 win.metafile("test.wmf") 命令一起使用。这里有什么问题?

4

2 回答 2

2

Windows 文件名不能包含以下字符:

< > : " \ / | ? *

请参阅此处以获取参考,或有关该主题的先前 SO 问题

于 2013-07-02T16:29:37.700 回答
1
 win.metafile(paste("plotname",format(Sys.time(),"%y%m%d.%M%H"),".wmf",sep=''))

为我工作。我认为问题出在文件格式上——根据 Hong Ooi 的回答,Windos 不允许在文件名中使用冒号。这将时间作为年/月/日.小时/分钟

查看http://stat.ethz.ch/R-manual/R-patched/library/base/html/strptime.html了解有关格式化的更多信息。您也可以添加不同的内容,例如:

format(Sys.time(),"%y see? %m")
于 2013-07-02T16:20:45.843 回答