如何强制R更新png文件创建日期?

如何强制R更新png文件创建日期?,r,R,我正在使用以下代码从我的绘图中创建.png: png(filename="H:/plot.png", width=650, height=875, units="px", res=100) grobz <- lapply(list(1.plot, 2.plot, 3.plot, 4.plot), ggplotGrob) grobz.plot <- arrangeGrob( grobs = list(rbind(grobz[[1]], grobz[[2]], grobz[[3]], g

我正在使用以下代码从我的绘图中创建.png:

png(filename="H:/plot.png", width=650, height=875, units="px", res=100)
grobz <- lapply(list(1.plot, 2.plot, 3.plot, 4.plot), ggplotGrob)
grobz.plot <- arrangeGrob( grobs = list(rbind(grobz[[1]], grobz[[2]], grobz[[3]], grobz[[4]], size = "last")), ncol = 1)
grid.draw(grobz.plot)
dev.off()
png(filename=“H:/plot.png”,宽度=650,高度=875,单位=px,分辨率=100)
grobz也许“”能帮上忙

虽然应该有一种更复杂的方法来更新写入/保存时间,但您可以使用
Sys.time()


time我无法更改路径或文件名,因为它们都用于其他工作。我希望只是以某种方式更改文件属性,除非这可能是Windows操作系统的问题?如果你不能完全理解,请原谅,但为什么不使用不同的变量呢?一个是固定的,另一个是随时间变化的。图像文件在其他脚本中由名称引用,因此随时间变化的名称将中断该过程。
time <- Sys.time()
#time <- as.Date(Sys.time()) # if you need only the date
path <- "~/somepath/"
path_name <- paste0(path, time, ".png") # the exact location with file name
png(filename=path_name , width=650, height=875, units="px", res=100)
# ...