Trying to use RWeka package

First I installed rJava successfully.

> install.packages("rJava")

the console read:

Installing package into ‘C:/Users/mlrob/Documents/R/win-library/3.4’

(as ‘lib’ is unspecified)

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-10.zip'

Content type 'application/zip' length 726859 bytes (709 KB)

downloaded 709 KB

package ‘rJava’ successfully unpacked and MD5 sums checked

Then I installed RWeka successfully (I thought)

>Install.packages("RWeka")

The console read:

The downloaded binary packages are in

C:\Users\mlrob\AppData\Local\Temp\RtmpkxMbwA\downloaded_packages

But I was unable to use RWeka. I typed in

>library(RWeka)

console returned this discouraging message:

Error: package or namespace load failed for ‘RWeka’:

.onLoad failed in loadNamespace() for 'rJava', details:

call: fun(libname, pkgname)

error: JAVA_HOME cannot be determined from the Registry

In addition: Warning message:

package ‘RWeka’ was built under R version 3.4.4

Thank you for any advice on how to fix this.

0 Upvotes

ReplyUnfollow this discussion

You can set the JAVA_HOME variable from your Rprofile.site or Renviron.site files, try adding something like this

#Change this path accordingly to your Java version and always match the architectures of R and Java (i.e. 64 or 32 bits)
Sys.setenv('JAVA_HOME'="C:/Program Files/Java/jdk-11.0.1/") 

Sys.setenv('JAVA_HOME'="C:/Program Files/Java/jdk-11.0.1/")
library(RWeka)
Error: package or namespace load failed for ‘RWeka’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/mlrob/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
package ‘RWeka’ was built under R version 3.4.4
install.packages("rJava")
Installing package into ‘C:/Users/mlrob/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-10.zip'
Content type 'application/zip' length 726859 bytes (709 KB)
downloaded 709 KB

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\mlrob\AppData\Local\Temp\Rtmp4glzPo\downloaded_packages

Sys.setenv('JAVA_HOME'="C:/Program Files/Java/jdk-11.0.1/")
library(RWeka)
Error: package or namespace load failed for ‘RWeka’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/mlrob/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
package ‘RWeka’ was built under R version 3.4.4

Thank you so much for your reply. My R package is 3.4.2. I will update it and try again.

This is just an example, you need to use your own path instead, are you also using Java 11?

If you are looking to use that package to get a C4.5 model (via the J48 function), you'd be better off using the C50 package (which does not use Java).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.