# RCall cannot install R packages

**URL:** https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624
**Category:** General Usage
**Tags:** question, package
**Created:** [December 10, 2020, 7:18pm UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624 "2020-12-10T19:18:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [December 10, 2020, 7:18pm UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624/1 "2020-12-10T19:18:10Z")

</div>

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:

```julia
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.

---

<div class="post-metadata">

### Author: ![haberdashPI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haberdashpi/32/26337_2.png) [@haberdashPI](https://discourse.julialang.org/u/haberdashPI)
#### Post date: [December 11, 2020, 2:22pm UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624/2 "2020-12-11T14:22:11Z")

</div>

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](https://cloud.r-project.org/)  
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.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [December 11, 2020, 2:32pm UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624/3 "2020-12-11T14:32:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [June 25, 2024, 10:27am UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624/4 "2024-06-25T10:27:34Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![haberdashPI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haberdashpi/32/26337_2.png) [@haberdashPI](https://discourse.julialang.org/u/haberdashPI)
#### Post date: [June 25, 2024, 11:57am UTC](https://discourse.julialang.org/t/rcall-cannot-install-r-packages/51624/5 "2024-06-25T11:57:32Z")

</div>

Correct!
