[英]Why file.exists(tempfile()) return FALSE?
今天有一个简单的问题,我找不到解决方案。 为什么file.exists()
返回FALSE? HD上有足够的空间,所以我不知道发生了什么。
file.exists(tempfile())
#> [1] FALSE
由reprex软件包 (v0.3.0)创建于2019-05-21
您得到该返回值,因为tempfile()
本身不会创建文件。 相反,如?tempfile
:
'tempfile'返回字符串的向量,可用作临时文件的名称。
要自己查看此内容,请尝试以下操作
## `f` is just a character string
f <- tempfile()
f
## [1] "C:\\tmp\\RtmpUdx1MU\\file26fc52b52d77"
class(f)
## [1] "character"
file.exists(f)
## [1] FALSE
## Writing something to the path given by `f` is what creates the file
cat("Hello", file = f)
file.exists(f)
## [1] TRUE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.