Error while using h2o.init() in R - r

I get the following error whenever I use h2o.init():
localh2o<-h2o.init()
H2O is not running yet, starting it now...
Error in system2(command, "-version", stdout = TRUE, stderr = TRUE) :
'""' not found
In addition: Warning message:
In .h2o.checkJava() :
Found JRE at C:/Program Files (x86)/Java/jre7/bin/java.exe but H2O requires the JDK to run
I am running it on RStudio Version 0.99.473 and R version 3.2.2, 64 bit os

The error message is pretty self-explanatory:
Found JRE at C:/Program Files (x86)/Java/jre7/bin/java.exe but H2O requires the JDK to run
You need to install the JDK and point the JAVA_HOME environment variable to the JDK directory (the parent of the bin directory), if it isn't automatically done by the installer.

Related

Install two versions of rtools

I have R version 4.0.2 and Rtools40 installed in windows on the local disk C:\. I recently installed Microsoft R Client version 3.5.2, in the local disk E:\. My question is how can I install Rtools35.exe on the E:\ disk without interfering with the Rtools40 variable environment?. In other words, I want to have both versions of rtools and that they work without problems, Thanks.
When switching to R 3.5.2, rtools does not work.
library(Rcpp);
evalCpp("2 * M_PI")
Error in system(cmd, intern = !showOutput) : 'E:/Program' not found
Error in system(cmd, ignore.stderr = TRUE, intern = TRUE) :
'E:/Program' not found
R 4.0.2 works
library(Rcpp);
evalCpp("2 * M_PI")
6.283185
Read the instructions at this page It should not be too hard to set up your two installation of R (4.0 and 3.6.X) so that each one queries a different .Renviron file and thus sets up a different path to the desired Rtools repository.
The problem was due to the fact that Microsoft R Client version 3.5.2, was installed in a path with space E:\Program Files\Microsoft\R Client, it was solved by installing it in a path without spaces E:\Microsoft\R-Client, such as suggested in: Message error 'C:/Program' not found with Rcpp

"Java exception occurred during rJava bootstrap" when trying to use tabulizer

I'm running Mac OS 10.13.6, and using RStudio 1.1.8, R 3.5.3, Java 11. In case hardware might matter, I'm using a 2013 MacBook Air.
I'm trying to run the extract_table function from the r tabulizer package on the Correlates of War World Religion Codebook, available here. I seem to be getting stuck because of an error with rJava. The rJava library seems to load in RStudio just fine, but when I run the following line:
lst <- tabulizer::extract_tables("/Users/[me]/Downloads/wrp-codebook-bibliography.pdf", encoding="UTF-8")
or try to load the tabulizer library, I receive the following error:
WARNING: Initial Java 12 release has broken JNI support and does NOT work. Use stable Java 11 (or watch for 12u if avaiable).
ERROR: Java exception occurred during rJava bootstrap - see stderr for Java stack trace.
Exception in thread "main" java.lang.NullPointerException
at java.base/jdk.internal.reflect.Reflection.verifyMemberAccess(Reflection.java:130)
at java.base/java.lang.reflect.AccessibleObject.slowVerifyAccess(AccessibleObject.java:673)
at java.base/java.lang.reflect.AccessibleObject.verifyAccess(AccessibleObject.java:666)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:638)
at java.base/java.lang.reflect.Field.checkAccess(Field.java:1075)
at java.base/java.lang.reflect.Field.get(Field.java:416)
Error: .onLoad failed in loadNamespace() for 'tabulizerjars', details:
call: .jcheck(silent = FALSE)
error: java.lang.NullPointerException.jcall(f, "Ljava/lang/Object;", "get", .jcast(ic, "java/lang/Object"))new("jobjRef", jobj = <pointer: 0x10caa0870>, jclass = "java/lang/NullPointerException")
EDIT: the below section has been update for clarity based on a comment received.
At first I thought it was that I needed to switch from Java 12 to Java 11, so I found a helpful post on SO and used the following commands to make that switch, with no instances of RStudio or R running while I did it:
MacBook-Air:~ $ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
12, x86_64: "Java SE 12" /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
11.0.2, x86_64: "Java SE 11.0.2" /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
MacBook-Air:~ $ export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-462`
The problem has persisted since them and when I double-check my version of Java in the terminal, I get this:
MacBook-Air:~ $ java -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
So it looks to me like I'm running 11.
However, I also still have 12 installed:
MacBook-Air:~ $ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
12, x86_64: "Java SE 12" /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
11.0.2, x86_64: "Java SE 11.0.2" /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
I'm not sure if R is looking at version 12 instead, or how to redirect it, or if there is another issue here all together. Unfortunately, I wasn't able to find anything on google or SO about this error specifically in the context of R and rJava.
Please let me know if I can provide any additional information.
Thanks!
Navigate to /Library/Java/JavaVirtualMachines and remove JDK 12
Reinstall JDK 11.
sudo R CMD javareconf in the terminal.
I re-installed rJava and it worked!
Using: install.packages("rjava")

Error loading a CPP file in RStudio with Microsoft R

I installed Microsoft R Open 3.5.1, tried to load a cpp with Rcpp::sourceCpp('TSDecompositionMissing.cpp') and I'm getting this error:
Error in system(cmd, intern = !showOutput) :
'C:/PROGRA~1/MIE74D~1/R' not found
I added the verbose flag and then I'm seeing:
...
Building shared library
--------------------------------------------------------
DIR: C:/Users/julio/AppData/Local/Temp/RtmpyqXrSJ/sourceCpp-x86_64-w64-mingw32-0.12.18/sourcecpp_88d456ea7b2a
C:/PROGRA~1/MIE74D~1/R Open/R-3.5.1/bin/x64/R CMD SHLIB -o "sourceCpp_4.dll" "" "TSDecompositionMissing.cpp"
Error in Rcpp::sourceCpp("TSDecompositionMissing.cpp", verbose = T) :
Error 127 occurred building shared library.
I checked my Sys.getenv() and I can see two relevant paths that do not exist (at least PROGRA~1 doesn't):
R_DOC_DIR C:/PROGRA~1/MIE74D~1/R Open/R-3.5.1/doc
R_HOME C:/PROGRA~1/MIE74D~1/R Open/R-3.5.1
Has somebody encountered this error before?
EDIT:
So, I realised the PATH C:/PROGRA~1/MIE74D~1/ exists and I think the problem is the folder after that which is named "R Open". It does not like the blank space
After Hong Ooi suggestion, I uninstalled Rtools 3.4, installed Rtools 3.5, reinstall MRO 3.5, R 3.5 and RStudio and now everything is working. The problem was probably RTools 3.5 was missing.

R unable to load internet routines after upgrade to MacOS Sierra

When running R after upgrading my mac to 10.12.6 (Sierra), R can no longer load libraries or access anything on the internet:
> install.packages("devtools")
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/anaconda/lib/R/doc/CRAN_mirrors.csv'
[...]
Warning: unable to access index for repository
https://cran.cnr.berkeley.edu/src/contrib:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘devtools’ is not available (for R version 3.4.1)
Similarly:
> source("https://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) :
internet routines cannot be loaded
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
This happens both when I run R from Terminal and when I run R from RStudio (though RStudio only gives me the error, not the warning, and then still fails).
I found other people with vaguely similar problems in the past; one common solution was to re-install XQuartz, which I have done, but which didn't help.
Another common solution was to update LD_LIBRARY_PATH. However, 'libssh2.1.dylib' does not seem to exist: 'locate libssh2.1.dylib' returns nothing. I did find libssh2.dylib in /Applications/Xcode.app/Contents/Developer/usr/lib/libssh2.dylib, which is presumably the same thing, but R isn't finding it, I suppose.
Any ideas? Thank you!
EDIT: I found a simple solution. Just download the .tar file and use the command 'R CMD INSTALL mcmcse_1.3-2.tar', for example, in your terminal, from the directory in which your .tar file is saved.
I think that install.packages(‘package_name’) not working within R on macOS Sierra (with the package manager Anaconda installed) might be because Anaconda moves R’s path.
Just a reply to flag the same issue while using Anaconda 4.2.0 with R 3.4.1 on macOS Sierra 10.12.6. I was initially running R 3.4.0 in /usr/bin/R, but R has since become R 3.4.1 in /Users/[username]/anaconda/bin/R after installing Anaconda 4.2.0.
Warning: unable to access index for repository https://www.stats.bris.ac.uk/R/src/contrib:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so':
dlopen(/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘mcmcse’ is not available (for R version 3.4.1)
This turns out to be, as far as I can tell, a bug in Anaconda2-4.4.0-MacOSX-x86_64.pkg I had an anaconda/ directory in /, /Applications/, and /Users/[me]/: I deleted all of them, and removed the Anaconda PATH change to .bash_profile. R then reverted to /usr/local/bin/R, which did not have the internet connection problems reported above. Then I reinstalled Anaconda from scratch, then installed RStudio from Anaconda-Navigator. 'which R' now pointed at /Users/[me]/anaconda/bin/R (the PATH having changed again upon install), and which had the internet connectivity problem. Running /usr/local/bin/R directly, even with Anaconda installed, had no problems.
I've filed the bug as https://github.com/Anaconda-Platform/support/issues/137 but now can at least run R myself by using /usr/local/bin/R.

R data.entry is not working on OS X El Capitan

When I use R language, I can't use data entry:
$ R
> cheese = c(1,2,3)
> data.entry(cheese)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: /usr/local/Cellar/r/3.2.2_1/R.framework/Resources/modules/R_de.so (No such file or directory)
Error in dataentry(odata, as.list(Modes)) : X11 is not available
In addition: Warning message:
running command ''/usr/bin/otool' -L '/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/modules/R_de.so'' had status 1
But I installed X11, XQuartz 2.7.7.
You need X11 support in order to use this function. Reinstall R with:
brew reinstall r --with-x11
It should then work as expected.
Installing 'R' from RStudio helped me in fixing this problem. I had installed 'R' using brew, therefore first uninstalled 'R' using command-
Atuls-MacBook-Pro:~ atulkaushik$ brew uninstall r
Then downloaded the appropriate package 'R-x.y.z.pkg' from RStudio. Though, this step helped me in running x11() on terminal, I was still not able to perform operations using this function.
m=matrix(1:81,9,9)
data.entry(m)
Error in .External2(C_dataentry, data, modes) :
unable to start data editor
In addition: Warning messages:
1: In dataentry(odata, as.list(Modes)) :
locale not supported by Xlib: some X ops will operate in C locale
2: In dataentry(odata, as.list(Modes)) : X cannot set locale modifiers
3: In dataentry(odata, as.list(Modes)) :
unable to create fontset --fixed-medium-r----120------
instead of invoking r shell through command 'r', I used LC_CTYPE=C R command
Atuls-MacBook-Pro:~ atulkaushik$ LC_CTYPE=C R
Now, when I execute
data.entry(m)
System will open a XQuartz window like -

Resources