Installing RWeka Package in R on OS X
I’m currently taking a data mining class, and I’m trying to do as much of the coding in the class using R for practice. We are using Weka 3 which so far is proving to be a pretty neat (FREE) data mining tool. To meet my goal of improving my R skills while taking this class I needed to find a way to read .arff data files from Weka into R so that I can access the data to run the assigned tasks.
The first option, which is what most of my classmates are doing, is of course is to load the data into Weka and convert it to a CSV file and then load that file into R using the read.csv() command. I was curious to see if I could do it more directly.
After some research I found that there are several options, one of which is the RWeka library. When I tried to install the RWeka package into RStudio (on Mac OS X) I ran into a few issues and errors mostly involving Java. Here is the solution I found after a lovely Sunday morning jumping from thread to the thread on the ever helpful Stack Overflow:
1. Relink R with the installed Java Library on OS X.
Open the terminal and run this command:
sudo R CMD javareconf
2. Install the rJava package in R.
I’m using RStudio here, but either way the command would be:
install.packages(“rJava”,type = “source”)
I was a bit worried about all those errors but then I realized I had already installed rJava before, hence the “restorng previous…” message. The “non-zero exit status” was probably a result of the previous errors, and I could not figure out what if there was another possible reason for it, so I decided to keep going.
3. Install the RWeka package in R (or RStudio):
The last step was to install the RWeka package, and then load the library. I have put those commands together here, but I ran the install first, got the success message, then loaded the library.
After that I was able to load the arff data file using the read.arff command and everything is working perfectly!
Hope this is helpful!