Reputation: 8044
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
Upvotes: 0
Views: 1578
Reputation: 12640
There are some APIs in Windows that are limited to 255 character paths. E.g. 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. )
Upvotes: 5