[R] Absolute path in gdata library

Marc Schwartz marc_schwartz at me.com
Thu Nov 8 00:12:35 CET 2012


On Nov 7, 2012, at 4:58 PM, r <ric.romoli at gmail.com> wrote:

> Dear list, 
> I have some .xls files that I need to read into R. I am able to do so
> using read.xls in the gdata package, however the helper functions
> sheetNames and sheetCount fail. This is the error:
> 
> Unable to open file '~/SharedFolder/MyData/mydata.xls'.
> Warning: running command ''/usr/bin/perl'
> '/usr/local/lib/R/site-library/gdata/perl/sheetCount.pl'
> '~/SharedFolder/MyData/mydata.xls'' had status 2
> 
> Googling I found that the problem is caused by the use of the absolute
> path ("~/SharedFolder/MyData/") instead of
> "/home/r/SharedFolder/MyData/". I use the absolute path because I work
> from different computer connected to a shared folder. 
> 
> This is the discussion I found:
> http://stackoverflow.com/questions/11737906/path-specification-when-using-the-r-package-gdata
> 
> Is there a way to solve this problem??
> 
> Best
> Riccardo


You can contact the package maintainer (cc'd here) and suggest that the use of:

  normalizePath()

be implemented in the code, which would then do tilde expansion, etc. when relative file paths are passed rather than absolute paths are used.

A workaround for now, would be to wrap your filename in that function in your code, so that when you use relative paths, the appropriate expansion is used and passed to the gdata function as the filename argument.

I just made this change myself in the WriteXLS package at the request of another useR.

Regards,

Marc Schwartz




More information about the R-help mailing list