[R] Unable to load a file: no such file or directory

Antonio Carazo acarazo at foss.es
Mon May 26 11:38:06 CEST 2014


Thank you Ray and Jim.
It works with file.choose().
I post following the output.

Antonio Carazo
Regional Sales Manager FOSS IBERIA.
Ph. D. student in Social Sciences.

> list.files()
 [1] "DATOS1.txt"             "open.exe"               "R.dll"                  "R.exe"                  "Rblas.dll"              "Rcmd.exe"              
 [7] "RCommander.R"           "RCommander.txt"         "RCommanderMarkdown.Rmd" "Rgraphapp.dll"          "Rgui.exe"               "Riconv.dll"            
[13] "Rlapack.dll"            "Rscript.exe"            "RSetReg.exe"            "Rterm.exe"              "Rzlib.dll"             
> DATOS1<-matrix(scan("E:/R 3.0.2/R-3.0.2/bin/x64/DATOS1.txt")
+ DATOS1
Error: inesperado símbolo in:
"DATOS1<-matrix(scan("E:/R 3.0.2/R-3.0.2/bin/x64/DATOS1.txt")
DATOS1"
> DATOS1()
Error: no se pudo encontrar la función "DATOS1"
> X
[1] 1
> DATOS1.txt
Error: objeto 'DATOS1.txt' no encontrado
> DATOS1 <- matrix(scan(file.choose()), ncol = 8)
Read 112 items
> 
> DATOS1
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
 [1,]   32    0   21   65   20    7   21   65
 [2,]   17   66   14  126    7   73   12  125
 [3,]   67   22   12   37   63   20   23   31
 [4,]  112   25   66   14  109   35   71   16
 [5,]   28   66   21   25   20   67   29    0
 [6,]   10  122    0   68   10  125   12   72
 [7,]   17   23   67   21   34   23   65   22
 [8,]   71   12  125    8   69   12  115    7
 [9,]   32   25   20   64   22   50   33   62
[10,]    9   68   15  123    6   72   13  113
[11,]   64   18    2   24   62   23    0   23
[12,]  142   25   67   12  123   25   69   14
[13,]   32   60   41    0   27   69   31   25
[14,]   14  101    7   71   12  167    0   78

-----Original Message-----
From: Ray Brownrigg [mailto:Ray.Brownrigg en ecs.vuw.ac.nz] 
Sent: lunes, 26 de mayo de 2014 07:16
To: Antonio Carazo; r-help en R-project.org
Subject: Re: [R] Unable to load a file: no such file or directory

On 26/05/14 10:25, Antonio Carazo wrote:
> 
> Hi,
> I have the file DATOS1 in the directory E:/R 3.0.2/R-3.0.2/bin/x64.
> If I try to load it, R returns me this error:
>> getwd()
> [1] "E:/R 3.0.2/R-3.0.2/bin/x64"
>> DATOS1<-matrix(scan("E:/R 3.0.2/R-3.0.2/bin/x64/DATOS1"),ncol=8)
> Error en file(file, "r") : no se puede abrir la conexión
> Además: Mensajes de aviso perdidos
> In file(file, "r") :
>   no fue posible abrir el archivo 'E:/R 3.0.2/R-3.0.2/bin/x64/DATOS1': 
> No such file or directory
> 
> The file DATOS1 is a Text Document with this composition:
> 32   17   67   112   28   10   17   71
> 32    9   64   142   32   14    0   66
> 22   25   66   122   23   12   25   68
> 18   25   60   101   21   14   12   66
> 21    0   67   125   20   15    2   67
> 41    7   65   126   37   14   25   68
> 21    8   64   123   24   12    0   71
> 20    7   63   109   20   10   34   69
> 22    6   62   123   27   12    7   73
> 20   35   67   125   23   12   50   72
> 23   25   69   167   21   12   23   71
> 29   12   65   115   33   13    0   69
> 31    0   65   125   31   16    0   72
> 22    7   62   113   23   14   25   78
> 

If it's a text document created with a Windows application, then it is very likely that the file name is really DATOS1.txt.  Another useful thing to do in Windows is to use file.choose() whenever you want to open a file:
DATOS1 <- matrix(scan(file.choose()), ncol = 8)

> The unit E: is an external hard disk.
> It seems like the path were wrong.
> I´ve read the FAQ´s, the Windows FAQ´s, the R document about scan() function and the related sections of An Introduction to R and the Import/Export manual, but I can´t find any answer of this error.
> Can anybody help me, please?
> Thank you
> 
Hope this helps,
Ray Brownrigg



More information about the R-help mailing list