Example 02: R and TidyVerse

Goal: Create an environment using the R language that includes the TidyVerse library.

Note: There is a known vulnerability with R versions less than 4.4.0.

This page uses R version 4.3.1. This page is purely for example since as of the date of creating this page there were issues using an r-base/4.4.1.

I am hoping in a few weeks/months the 4.4.x base will be stable and I’ll update the examples.



General Process

[]$ conda create -n r_env r=4.3.1 []$ conda activate r_env (r_env) []$ R --version R version 4.3.1 (2023-06-16) -- "Beagle Scouts" ... (r_env) []$ conda search tidyverse ... (r_env) []$ conda install r-tidyverse=2.0.0 (r_env) []$ R > library(tidyverse) ── Attaching core tidyverse packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ── ... > quit() Save workspace image? [y/n/c]: n (r_env) []$ conda deactivate []$

Create R Environment

[]$ conda create -n r_env r=4.3.1 Channels: - defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: /project/<project-name>/<username>/conda/envs/r_env added / updated specs: - r=4.3.1 ...

Notice we can include the R language package (previously defined in a separate conda install ... in the creation line.

The environment install location has been updated to: environment location: /project/arcc/salexan5/conda/envs/r_env as configured.


How to Activate

... Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use # # $ conda activate r_env # # To deactivate an active environment, use # # $ conda deactivate

Did Search Work?


Conda Install TidyVerse


How Large is this Environment?

Confirm where this R environment is located.


Using R Environment

File: r_test.R