gpt4 book ai didi

r - 尽管在 list.files 中,为什么 file.exists 返回 FALSE?

转载 作者:可可西里 更新时间:2023-11-01 09:57:41 25 4
gpt4 key购买 nike

我有一个文件 x 出现在目录中,正如 list.files 所证明的那样

x <- "./data-raw/paths/calculate-route-by-FROM-TO/2017-05-2075--FROM-Flinders-Street-Railway-Station--Melbourne-Victoria-3004--VIC--TO-Melbourne-Sports-Aquatic-Centre--30-Aughtie-Dr--Melbourne-VIC-3206--VIC-csv"
x %in% list.files("./data-raw/paths", recursive = TRUE, full.names = TRUE)
# [1] TRUE
file.exists(x)
# [1] FALSE

请注意 x 缺少扩展名,但我在 ?file.exists 中找不到这样的警告:

file.exists returns a logical vector indicating whether the files named by its argument exist. (Here ‘exists’ is in the sense of the system's stat call: a file will be reported as existing only if you have the permissions needed by stat. Existence can also be checked by file.access, which might use different permissions and so obtain a different result. Note that the existence of a file does not imply that it is readable: for that use file.access.) What constitutes a ‘file’ is system-dependent, but should include directories. (However, directory names must not include a trailing backslash or slash on Windows.) Note that if the file is a symbolic link on a Unix-alike, the result indicates if the link points to an actual file, not just if the link exists. Lastly, note the different function exists which checks for existence of R objects.

文档中的唯一提示是访问限制可能会导致 FALSE,而实际上 file.access(x)-1 但是我似乎可以访问该文件(以及其他没有受到太大影响的非常相似的文件)。

最佳答案

Windows 对文件名的长度(260 个字符)有上限,x 超过了上限。缩短文件导致 file.exists 返回 TRUE

关于r - 尽管在 list.files 中,为什么 file.exists 返回 FALSE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44159751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com