问题
I am currently using R for Windows verison 3.5.3 and RStudio version 1.2.1335.
My goal is to import an ARFF dataset using the RWeka package in order to do some Association analysis, more specifically, to apply the Apriori algorithm.
I want to analyze a dataset (.ARFF) in R and, due to convenience, I am using the RWeka package, as my goal is to apply the Apriori algorithm, one of the associators available on that package.
That package requires some dependencies (RWekajars e rJava) and they were successfully installed.
However, when I try to run the script (I'll leave the script bellow), I always get an error related with one of the dependencies (onLoad failed in loadNamespace() for 'rJava'
).
Any guidance is appreciated.
Script
library(rJava)
library(RWeka)
x <- read.arff(system.file("arff", "movies_2.arff", package = "RWeka"))
Apriori(x)
Apriori(x, Weka_control(N = 20))
Errors:
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/USER/Documents/R/win-library/3.5/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
x <- read.arff(system.file("arff", "movies_2.arff", package = "RWeka")) Error in read.arff(system.file("arff", "movies_2.arff", package = "RWeka")) : could not find function "read.arff"
Apriori(x) Error in Apriori(x) : could not find function "Apriori"
Apriori(x, Weka_control(N = 20)) Error in Apriori(x, Weka_control(N = 20)) : could not find function "Apriori"
回答1:
Getting the rJava to work relies on one's computer configurations.
You may need to install JAVA for your R version. Usually when one installs JAVA it installs the 32bit version, but if you want to install JAVA 64-bit follow this link.
One will also need the JDK, if you want to install it follow this link.
I am using Windows 10 (64 bits) and I also had to make sure that the environment variable JAVA_HOME
was not set (not sure why).
Sys.setenv(JAVA_HOME='')
回答2:
Could be that you do not have Java installed on that machine. Make sure you have the JRE installed.
https://www.java.com/en/download/
Update: Following indicates Java is missing
https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
Also remember to install the weka since they are in separate package RWekajars
来源:https://stackoverflow.com/questions/55692355/import-arff-dataset-using-rweka-in-rstudio-depencendy-error-rjava