RWeka Issue Knitting HTML - r

I'm getting the error below involving the RWeka library, when trying to knit a markdown file into html with Knitr in Rstudio. Any tips would be greatly appreciated.
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Quitting from lines 14-20 (Milestone_Report.Rmd)
Error: package or namespace load failed for 'RWeka'
Execution halted

Please install latest version of Java and set value for JAVA_HOME variable as the directory where you installed Java. Once done try library(RWeka) and see if you are getting error. Hope this should solve the problem.

Related

rjags installation error, can't find JAGS path on Windows

I'm having an issue getting rjags to load & run. I can install rjags, but it doesn't run because it can't find JAGS. My versions are listed below and are all updated to the latest versions. I'm also using a Thinkpad.
JAGS Version: 4.3.0
RStudio Version: 2021.09.0 Build 351
Installation of rjags is okay using the following command:
install.packages('rjags',configure.args="--enable-rpath")
Error messages recopied below:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0
but no JAGS installation can be found there
If I go to where JAGS is installed, the path is:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS
I used the above lines shared to try and solve this problem, but to no avail:
Sys.setenv(JAGS_HOME="C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0")
Error: unexpected '/' in "Sys.setenv(JAGS_HOME=C:/"
Corrected to:
Sys.setenv(JAGS_HOME="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS\JAGS-4.3.0")
Error: '\P' is an unrecognized escape in character string starting ""C:\P"
Corrected to:
Sys.setenv(JAGS_HOME="C:\ ProgramData\ Microsoft\ Windows\ Start Menu\ Programs\ JAGS\ JAGS-4.3.0")
This doesn't yield any errors, but when I try to load rjags I get the following:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C: ProgramData Microsoft Windows Start Menu Programs JAGS JAGS-4.3.0
but no JAGS installation can be found there
This is the same as above, but the / are left out for some reason.
Unsure of what to try next, any thoughts/insight would be much appreciated! :)
This seems to be an issue others have faced too: rjags failed to load and R Failed to locate any version of JAGS
https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/060fd5c378/?limit=25
https://www.reddit.com/r/rstats/comments/pzto5t/rjags_is_my_enemy/
Though none of these solutions seem to be working (yet?).
Problem solved!
Both of you were right - JAGS was in an odd location, so I moved it to:
C:\Program Files\JAGS\JAGS-4.3.0
And then used the code (I think / is the same as \):
Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.0")
And now it works like a charm :)

R error loading package rJava and openNLP

I get this error message while trying to load the rJava or the openNLP packages through the function library(openNLP) or library(rJava):
Error: package or namespace load failed for ‘rJava’:
.onLoad in loadNamespace() for 'rJava' failed, details:
call: dirname(this$RuntimeLib)
error: a character vector argument expected
I have no problems loading other packages, e.g. NLP.
Does somebody know what the problem is?
I have updated the Java SE Development Kit and now I get no error message anymore. So this seems to be the solution for the problem.
I solved this problem by installing Java SE Development Kit 8.
Link for Download: http://www.oracle.com/technetwork/pt/java/javase/downloads/jdk8-downloads-2133151.html

rJava access issue in R3.3.0 (Windows XP)

I need to use the package "xlsx" to export some data on R to excel, but that package requires rJava to run. Whenever I use library(rJava) to call rJava, I get the following error:
Error:.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package 'rJava' could not be loaded
I honestly cannot make heads or tails of it. What can I do to fix it?

Loading R package xlsx: Error : .onLoad failed in loadNamespace()

I tried to load the R package xlsx:
library('xlsx')
But I got the following error:
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: Cannot create Java virtual machine (-1)
In addition: Warning message:
package ‘xlsx’ was built under R version 3.2.3
Error: package or namespace load failed for ‘xlsx’
My R-session aborts when I try .jinit()
Any help is much appreciated.
Edit:
I updated R Studio to the newest version and executed
update.packages(checkBuilt = TRUE)
but still got the following error:
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: Cannot create Java virtual machine (-1)
Error: package or namespace load failed for ‘xlsx’
Edit 2:
This question is still unsolved.
As Pascal in the comments below suggested I looked for the windows equivalent command of:
R CMD javareconf
After many hours of searching I still didn't found it.
I faced similar problem on Macbook. If you've upgraded Java recently, it is likely that you need to reconfigure.
For me, it got solved with,
step#1 sudo R CMD javareconf (On Windows, sudo not required. If you face "command not found" issue on Windows, try this)
step#2 install.packages("rJava",type='source') (inside R prompt)
Hope this helps!
In case you don't have PATH variable set up properly, try to override it by using
options(java.home="PATH TO jre")
This might fix some issues.

RJava and XLConnect in RStudio not loading

First the tech specs of what I am using:
RStudio 0.98.983
R 3.1.1 (64 Bit)
Windows 8.1
When trying to load XLConnect I receive the following error
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘XLConnect’
When trying to load RJava I receive the following error
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘rJava’
I've checked to make sure the newest updates are installed from CRAN. However I am out of ideas and new to R. Does anyone know how to fix this?
Here is what I posted before:
Meanwhile, I am right now having the problem with the relenium package, which can't locate rJava.
Version mismatches can bedevil you. Check that if your version of R is 32 byte, so must your Java version be. Or, 64 byte must match 64 byte.
Second, I ended up adding to my PATH (I am on Windows 8) the location of the jv.dll file that XLConnect needs (I think that was the name of the file). I found the PATH through Control Panel and System Environment (and maybe more).
Third, the Java site will verify that you have Java installed.
Fourth, with the matching architecture and the PATH pointing to the needed .dll file, I rebooted and it all worked.
Good luck.

Resources