R with Conda

I’ve been unable to get some R libraries to install on my Linux laptop. Two libraries in particular were tseries and tidyverse. The same libraries installed just fine on Windows. (Maybe you need to install Rtools first before installing these on Windows; I don’t remember.)

I use conda all the time with Python, but I hadn’t tried it with R until this evening. Apparently it just works. The libraries I was trying to install have a lot of dependencies, and conda is very good at managing dependencies.

I removed my installation of R and reinstalled from conda:

    conda install r-base

Then I installed tseries with

    conda install r-tseries

and installed tidyverse analogously:

    conda install r-tidyverse

Just prepend r- to the name of the R library you want to install.

I haven’t used it in anger yet, but it seems that everything works just fine.

5 thoughts on “R with Conda

  1. It may be irrelevant now that you have it installed through conda, but tidyverse has never posed a problem on either my desktop or my laptop (both running Linux Mint). I don’t recall if it needs rJava, which can be a bit finicky to install. If you decide you need the original (non-conda) version, and you run into problems, you might post the output from the installer, along with which Linux distribution you are using.

  2. Michael Hannon

    It’s interesting to know that conda works smoothly with R, but I note that it’s trivial to install both of the packages you mention
    directly from CRAN, i.e., within R. I just tried it:

    > install.packages(“tseries”)
    > install.packages(“tidyverse”)

    No problem with either.

    > sessionInfo()
    R version 3.6.0 (2019-04-26)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Ubuntu 18.04.2 LTS

  3. Rather than say it’s trivial, I’d say it can be trivial. It was trivial on one of my computers but not on another one. On one the install.packages() commands worked and on another they did not.

    I’ve often had trouble managing library versions with R. I’d try to use install.packages and it would fail. I’d end up wiping out R and all its libraries, then reinstalling the latest version of everything. That usually works, though even that didn’t work in the situation I wrote about.

  4. Michael Hannon

    I’ve seen problems with R packages that were at least somewhat similar to the problems you mention. They were typically related to permission problems and/or updates to R itself. But there are well-known solutions to both. If you send me a log (or screenshot or …) of an instance of your problem, I’ll see if I can provide any useful advice.

Leave a Reply

Your email address will not be published. Required fields are marked *