Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 2.83 KB

Installing_R_packages_with_conda.md

File metadata and controls

70 lines (55 loc) · 2.83 KB

Installing the changeforest R package with conda

Conda is an open source package management system. Conda enables maintaining and switching between environments on your computer. It was created for Python programs, but can distribute packages for any language (including R).

I personally manage my R packages and their dependencies with conda. This is a short manual on installing the changeforest R package with conda. The changeforest R package is available for Mac and Linux, not Windows as of yet. More detailed descriptions on how to manage R dependencies with conda exist online. There is also a cheatsheet with commonly used commands.

If you do not have conda installed on your system, download an installer corresponding to your OS and architecture here. I would recommend Miniforge3 or Mambaforge. Follow the installation instructions, making sure to run conda init bash or conda init zsh at the end as described. Also, restart your shell (e.g., by closing and reopening the terminal). Afterwards, your terminal should look something like this:

(base) ~ $ 

The (base) indicates that you are in the base environment. I personally don't recommend installing packages directly into the base environment. First create a new environment R and activate the new environment:

(base) ~ $ conda create --name R
(base) ~ $ conda activate R
(R) ~ $

Next, install r-essentials and r-changeforest:

(R) ~ $ conda install -c conda-forge -y r-base r-changeforest

The -c conda-forge tells conda to install r-changeforest from the open-source channel conda-forge. There, R packages are available with the r- prefix. E.g., to install MASS, run

(R) ~ $ conda install -c conda-forge -y r-mass

Congratulations, you installed R and changeforest with conda. Now, you should be able to import changeforest in an interactive R session:

(R) ~ $ R

R version 4.1.3 (2022-03-10) -- "One Push-Up"
...
> library(changeforest)

If you are using R Studio, this should pick up the conda R installation given that you activated the correct environment first. You can check whether R Studio is using the correct R installation by checking R.home() (or library(changeforest)). I personally do not use R Studio, so do not have experience with this. Here is a StackOverflow exchange with more information.

If any of the above does not work for you, please feel free to open an issue.