Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何检查绘图是否已写入R中的文件_R_Plot - Fatal编程技术网

如何检查绘图是否已写入R中的文件

如何检查绘图是否已写入R中的文件,r,plot,R,Plot,如果我执行下面的R代码,将创建一个文件 png('tempfile.png', width = 500, height = 500) plot(1:10) dev.off() 如果我不策划任何事情。没有创建任何文件 png('tempfile.png', width = 500, height = 500) #plot(1:10) dev.off() 检查文件是否已创建的最佳方法是什么?您可以使用file.exists file.exists("tempfile.png") 如果要修改文件

如果我执行下面的R代码,将创建一个文件

png('tempfile.png', width = 500, height = 500)
plot(1:10)
dev.off()
如果我不策划任何事情。没有创建任何文件

png('tempfile.png', width = 500, height = 500)
#plot(1:10)
dev.off()

检查文件是否已创建的最佳方法是什么?

您可以使用
file.exists

file.exists("tempfile.png")

如果要修改文件,还可以使用
mtime
列中的
file.info
检查上次修改文件的时间。还有创建时间
ctime
和上次访问时间
atime
以及其他一些您可能感兴趣或不感兴趣的指标。

看起来这是唯一的可能性。非常感谢。我希望有一种直接的方式来获得反馈,无论情节是否已写入文件。我会接受这个答案。