RCall cannot install R packages

Hi I have an issue with RCall.jl

Firstly, thank you for this package, I have found RCall really useful.

Unfortunately, I cannot install R packages when I am in ‘R’ mode.

I get the error:

Warning in install.packages("ISLR") :
  'lib = "<my home dir>/miniconda3/lib/R/library"' is not writable
Error in install.packages("ISLR") : unable to install packages

As far as I can tell all of my home directory is writeable, so I can’t see what the issue is.

I could install the packages from R and then relaunch in Julia, but I am trying to teach a course and just use one REPL.

Does anyone have any ideas?

Thanks

**** Since I posted this, I found that there was an ownership issue, I do not know if this arose because of RCall, but I am pretty sure it must be, since I had no issues installing packages in R natively. I manually fixed this, but alas I fear my students won’t know how.

I’m guessing the problem here is that you installed RCall.jl by using Conda.jl (e.g. set ENV["R_HOME"] = "*"). If this is what’s happening in your case there are two ways to solve the problem.

  1. You can install the package via Conda. Note that it is a different repository from CRAN, so not all packages exist in Conda. (Though it is worth looking at the conda-forge channel, which is more comprhensive). For example, you might be able to type using Conda; Conda.add("r-ISLR", channel = "conda-forge"). The name of the package will vary, so the best thing to do is to google ‘conda ISLR’ etc… and see if it is available.

  2. You can re-build RCall.jl, pointing it to your own version of R.
    a. Download and install R
    b. Point RCall.jl to your installation of R: this step depends on your operating system, but will invovle setting ENV["R_HOME"] = [driectory here] with the directory set to the location of the folder that has the R binary you installed in step a.
    c. Rebuild RCall: using Pkg; Pkg.build("RCall")
    d. install your package: using RCall; R"install.packages('ISLR')"

Personally I have found that the dependency story for R is somewhat lacking in Julia. I have run into problems myself where there are bugs in running R without using Conda, and packages unavailable in Conda. I hope some day BinaryBuilder will make it possible to install R dependencies. Don’t know how realistic that is.

3 Likes

Hi David,

Thanks very much for that.

I corrected the ownership of the directory manually, and that seemed to work for me,
but your comments are helpful for my trouble-shooting students’ experience when they
try this.

I have played around with this a bit, and it looks pretty neat otherwise (much handier than
R’s JCall).

Cheers,

DavidE

1 Like

Hello, just to be sure I understood it correctly, if I installed RCall with the conda-based version of R ( ENV["R_HOME"] = "*") and I want to install a R package, say ggplot2, I can’t simply use the R command (install.packages('ggplot2')) but I need to use Conda.add("ggplot2") from the Conda.jl package, right ?

Correct!

1 Like