R 看不到磁盘上存在的文件

R doesn't see a file that exists on a disk

我正在尝试将磁盘上的文件读入 R - list.files 函数可以看到他,但是 file.existsread.table 看不到...

可能是什么原因导致 R 看不到某些文件并因此无法读取它们?

代码和错误如下:

> list.files(x)
[1] "ACC.rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.data.txt"
[2] "MANIFEST.txt"                                                                                
> list.files(x)[1]
[1] "ACC.rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.data.txt"
> file.exists(paste0(x,list.files(x)[1]))
[1] FALSE
> x
[1] "D:/GitHub/RTCGA.data/RTCGA.rnaseq/data2/gdac.broadinstitute.org_ACC.Merge_rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.Level_3.2015060100.0.0/"
> read.table(paste0(x,list.files(x)[1])) -> y
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'D:/GitHub/RTCGA.data/RTCGA.rnaseq/data2/gdac.broadinstitute.org_ACC.Merge_rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.Level_3.2015060100.0.0/ACC.rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.data.txt': No such file or directory

Windows 中的一些 API 限制为 255 个字符路径。例如。参见 Has Windows 7 Fixed the 255 Character File Path Limit?

此处的总路径长度为 269 个字符。我会认为这是问题所在。我会重命名文件夹、文件或两者。或者我想您可以更改 OS,但这似乎更难! (请注意,我使用 Windows 作为我的主要 OS 是出于选择,但我确实发现它的一些限制有时令人沮丧,特别是对于像 R 这样的跨平台工具。)