简体   繁体   中英

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

I am trying to read a file into R that is on my disk - list.files function sees him but file.exists and read.table do not...

What might be cause of that R doesn't see some files and in consequence can't read them?

The code and errors are below:

> 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

There are some APIs in Windows that are limited to 255 character paths. Eg See Has Windows 7 Fixed the 255 Character File Path Limit?

Your total path length here is 269 characters. I would have thought that was the issue. I would rename the folder, the file or both. Or I guess you could change OS, but that would seem harder work! (Note I use Windows as my main OS out of choice, but I do find some of its limitations frustrating at times, particularly for cross-platform tools like R. )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM