I am working with a Mathematica script that calls several functions in R 4.1.1 using the functions InstallR and REvaluate, and I am having some difficulty in specifying the path Mathematica needs to link to R.
I thought that the InstallR function should have something along the lines of:
InstallR["RHomeLocation" -> "/opt/R-4.1.1/bin/"]
since /bin contains the actual R executable. However, this doesn't seem to work, I get a series of error message. I'm still unclear as to what directory level I need to specify, or (in the context of the error message) what the "bundled JRI native library" is:
InstallR::nojrilib: RLink does not yet contain a bundled JRI native library for R version being installed. This library can be built manually from within R console (happens automatically when installing rJava Rpackage, see RLink documentation for using RLink with external R distributions, for more details). For the built JRI library to be found by InstallR[], the directory containing it (typically R-home-directory/library/rJava/jri) should be passed to InstallR[] as a value for "JRINativeLibraryLocation" option.
with corresponding stack trace:
*Message[InstallR::nojrilib, If[ListQ[{}], Sequence @@ {}, {}]]; Failure["JRINativeLibraryError", \ <|"FailureReason" -> "nomatchingjrilibversionsavailable"|>]*
I also attempted to link to one level up in the R directory, i.e.
InstallR["RHomeLocation" -> "/opt/R-4.1.1/"]
This seems to lead to an unbounded recursion of some kind, because I get an error message stating that Mathematica's iteration limit of 4096 has been exceeded (clearly implying that I'm at the wrong level of the path for Mathematica to find the executable).
One possible complication is that in the server that I'm working on, the default version of R that runs if one just types "R" in the console is 4.3.0. Therefore, to actually execute R, I need /opt/R-4.1.1/bin//R. Perhaps this is what is causing the problem with REvaluate - if so, what path do I need to specify?