[英]Why file.exists(tempfile()) return FALSE?
A simple question today for which I can't find a solution. 今天有一个简单的问题,我找不到解决方案。 Why file.exists()
returns FALSE? 为什么file.exists()
返回FALSE? I have plenty of space on my HD, so I do not understand what is going on. HD上有足够的空间,所以我不知道发生了什么。
file.exists(tempfile())
#> [1] FALSE
Created on 2019-05-21 by the reprex package (v0.3.0) 由reprex软件包 (v0.3.0)创建于2019-05-21
You're getting that return value because tempfile()
does not itself create a file. 您得到该返回值,因为tempfile()
本身不会创建文件。 Instead, as described in ?tempfile
: 相反,如?tempfile
:
'tempfile' returns a vector of character strings which can be used as names for temporary files. 'tempfile'返回字符串的向量,可用作临时文件的名称。
To see this yourself, try the following 要自己查看此内容,请尝试以下操作
## `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.