David.Lowery at csiro.au
2006-May-09 01:34 UTC
[R] read.table (Error in file(file, "r") : unable to open connection)
G?day, I am trying to read in a table and am getting an error message stating that R is unable to open a connection to the file. ? Avonvegen<- read.table("Y:\Study Sites\Avon\nonspatial\datafiles\archive\Avon_VegEnh.dat ", sep=",", na.string="-9999", header=TRUE) Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open file 'Y:Study SitesAvon onspatialdatafilesrchiveAvon_VegEnh.dat ', reason 'Invalid argument'>I have checked that the AvonVegEnh.dat is spelt correctly and has no hidden extensions. I have checked that the folder is accessible. I have moved the datafile and changed the script to try reading from the local drive with no success. I have used the same syntax on a similar file (same field structure but different data) with no problems before and now it doesn't read either. Does anyone have any ideas? Thanks, david
Gabor Grothendieck
2006-May-09 01:38 UTC
[R] read.table (Error in file(file, "r") : unable to open connection)
See 2.16 of the R Windows FAQ. On 5/8/06, David.Lowery at csiro.au <David.Lowery at csiro.au> wrote:> G'day, > > I am trying to read in a table and am getting an error message stating that R is unable to open a connection to the file. > > ? Avonvegen<- read.table("Y:\Study Sites\Avon\nonspatial\datafiles\archive\Avon_VegEnh.dat ", sep=",", na.string="-9999", header=TRUE) > Error in file(file, "r") : unable to open connection > In addition: Warning message: > cannot open file 'Y:Study SitesAvon > onspatialdatafilesrchiveAvon_VegEnh.dat ', reason 'Invalid argument' > > > > I have checked that the AvonVegEnh.dat is spelt correctly and has no hidden extensions. > I have checked that the folder is accessible. > I have moved the datafile and changed the script to try reading from the local drive with no success. > > I have used the same syntax on a similar file (same field structure but different data) with no problems before and now it doesn't read either. > > Does anyone have any ideas? > > Thanks, > david > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
ronggui
2006-May-09 01:42 UTC
[R] read.table (Error in file(file, "r") : unable to open connection)
I guess you use R under windows,then use \\ instead of \. or use file.choose() to choose the file directly. 2006/5/9, David.Lowery at csiro.au <David.Lowery at csiro.au>:> G'day, > > I am trying to read in a table and am getting an error message stating that R is unable to open a connection to the file. > > ? Avonvegen<- read.table("Y:\Study Sites\Avon\nonspatial\datafiles\archive\Avon_VegEnh.dat ", sep=",", na.string="-9999", header=TRUE) > Error in file(file, "r") : unable to open connection > In addition: Warning message: > cannot open file 'Y:Study SitesAvon > onspatialdatafilesrchiveAvon_VegEnh.dat ', reason 'Invalid argument' > > > > I have checked that the AvonVegEnh.dat is spelt correctly and has no hidden extensions. > I have checked that the folder is accessible. > I have moved the datafile and changed the script to try reading from the local drive with no success. > > I have used the same syntax on a similar file (same field structure but different data) with no problems before and now it doesn't read either. > > Does anyone have any ideas? > > Thanks, > david > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- ??? Deparment of Sociology Fudan University