2

I am reading a (sparse) arff using read.arff method of RWeka package. However I get the following error:

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

The file I am trying to read in exists (file.exists('myfile.arff') return TRUE).

My one line code is:

data = read.arff(system.file('arff', 'myfile.arff', package='RWeka'))

Any ideas what might be going on?

Thanks.

Edit 1: traceback() output

> traceback()
4: stop(list(message = "java.io.FileNotFoundException:  (No such file or directory)", 
   call = .jnew("java/io/FileReader", file), jobj = <S4 object of class "jobjRef">))
3: .External("RcreateObject", class, ..., silent = silent, PACKAGE = "rJava")
2: .jnew("java/io/FileReader", file)
1: read.arff(system.file("arff", "/home/andy/r/myfile.arff", 
   package = "RWeka"))
Andy
  • 328
  • 3
  • 13
  • I would (1) verify that the file does in fact exist, and (2) try passing the full path to the file to read.arff directly. These steps may provide you with more information about what's going on. – joran Dec 31 '11 at 18:35
  • I did 1 already (using file.exists) as I posted above. I passed the full path also. Same result. – Andy Dec 31 '11 at 18:56
  • Thanks for indulging me...sadly that was the extent of how helpful I'm going to be. Sorry! – joran Dec 31 '11 at 18:58
  • Does `traceback()` give anything useful? – Roman Luštrik Dec 31 '11 at 19:01
  • @RomanLuštrik : Just edited my question with output of traceback(). Not sure what to make of it. I am new to R. – Andy Dec 31 '11 at 19:08

1 Answers1

4

You seem to be using the format of the example in help(read.arff) without understanding why it is written using the system.file() function. If your .arff file is not in the package directory (and it does not appear to be so located), then you should not be using that function. Try instead:

mydat <- read.arff(file= "/home/andy/r/myfile.arff")

Or maybe just this if it is in your working directory:

mydat <- read.arff(file= "myfile.arff")
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Yes, indeed. R is reading in the ARFF now, but it seems to be very slow and memory consuming. WEKA reads in the same arff in <10secs and R has been trying to read it for over 15mins now and is still not done. Any thoughts on this? – Andy Dec 31 '11 at 20:12
  • Just want to add that this is probably because read.arff tried to read sparse data into a data frame and that probably is the bottleneck. Correct? If that is the case, can I read it directly into a sparse data structure? – Andy Dec 31 '11 at 20:22
  • I have no insight into your efficiency issues. It's not even clear that that your process is completing from what is written above. – IRTFM Dec 31 '11 at 20:33
  • Yes I had to kill the task after 1/2hr since it was clear that it was going nowhere. Thanks for your help though. – Andy Dec 31 '11 at 20:40
  • I looked at the code in the `read.arff` function in package "foreign" and it is different, so perhaps you could try it instead. (But in my rhelp moderator role I just now approved your posting to r-help saying you already considered that.) – IRTFM Dec 31 '11 at 21:11
  • foreign does not read in data in sparse arff format unfortunately :-( Even if I convert my data into non-sparse format, it will take a really long time to load in. Is there a way to read in data from external file (ARFF, CSV or whatever) directly into sparse data structure like Matrix or sparsem without having to first read it into a data frame? – Andy Dec 31 '11 at 21:15
  • Thanks. I am not counting on r-help list though. Never received a reply to any of my queries thus far ! – Andy Dec 31 '11 at 21:23
  • You might consider checking this one as answered and submitting a new on since many people will not be reading this far down the comments. – IRTFM Dec 31 '11 at 21:34
  • @DWin -- I know this is off-topic, but have never been able to figure it out. I am subscribed to the R-help list, and know how to post a question. But how do I post a reply? I usually browse it via [the archives](https://stat.ethz.ch/pipermail/r-help/), so if I see something there I'd like to respond to, what should I do? Copy the entire text into my own email program, prepend "RE:" to the subject line, and send to r-help@r-project.org ? (Please let me know if you'd rather me ask this as an SO question for others to see. And thanks!) – Josh O'Brien Jan 01 '12 at 00:04
  • I get my rhelp postings on a mail-client, and just hit `reply-all`. I'm not sure how you would properly reply if you have disabled mail delivery as it sounds as though you have. Sending a reply in the manner you suggest would almost certainly get to the list, but I do not know if all the recipients would see it threaded correctly without the "in-reply-to' information that mail clients gnerally add, eg a recent reply of mine had this in its headers: `In-Reply-To: <1325287199.27944.0.camel@milan>` – IRTFM Jan 01 '12 at 01:45