2

I am trying to use the R package xlsx to load a file available at this URL: http://www.plosgenetics.org/article/fetchSingleRepresentation.action?uri=info:doi/10.1371/journal.pgen.1002236.s019

library(xlsx)
filename="/home/avilella/00x/mobile.element.insertions.1000g.journal.pgen.1002236.s019.xlsx"

system(paste("ls -l",filename))
-rw-rw-r-- 1 avilella avilella 2372143 2011-12-11 16:36 /home/avilella/00x/mobile.element.insertions.1000g.journal.pgen.1002236.s019.xlsx

Once downloaded, I try to load it in R using read.xlsx or read.xlsx2:

file <- system.file("mobile.element.insertions.1000g", filename, package = "xlsx")
res <- read.xlsx2(file, 1)  # read first sheet

But I get an error:

Error in .jnew("java/io/FileInputStream", file) : java.io.FileNotFoundException: (No such file or directory)

Any ideas?

MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
719016
  • 9,922
  • 20
  • 85
  • 158
  • 1) make sure you're in the correct directory. 2) make life easy on yrself, and rename the file to something short&sweet w/o all the dots. – Carl Witthoft Dec 11 '11 at 17:01

1 Answers1

2

1) xlsx package. Try using file.choose which will allow you to interactively navigate to the file and thereby eliminate the possibility of misidentifying it:

fn <- file.choose()
DF <- read.xls(fn, 1)

2) gdata package. If the above still does not work then you might try read.xls in gdata. It uses a perl program rather than java. It can read both xls and xlsx files and can read data right off the net (downloading it into a temporary file and reading it from there in a manner that is transparent to the user):

library(gdata)
URL <- "http://www.plosgenetics.org/article/fetchSingleRepresentation.action?uri=info:doi/10.1371/journal.pgen.1002236.s019"
DF <- read.xls(URL)

?read.xls in gdata has more info.

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341