Using R language with Anaconda#
With Anaconda (or Miniconda), you can easily install the R programming language and over 6,000 commonly used R packages for data science. You can also create and share your own custom R packages.
When using conda to install R packages, you will need to add
r- before the regular package name. For instance, if you want to install rbokeh, you will
need to use
conda install r-rbokeh or for rJava, type
The R Essentials bundle contains approximately 200 of the most popular R packages for data science, including the IRKernel, dplyr, shiny, ggplot2, tidyr, caret, and nnet. It is used as an example in the following guides.
R is the default interpreter installed into new environments.
You can specify the R interpreter with the
r-base package. Unless
you change the R interpreter, conda will continue to use the default
interpreter in each environment.
To run the commands below on Windows, use Start - Anaconda Prompt. On macOS or Linux, open a terminal.
Updating R packages#
Update all of the packages and their dependencies with one command:
conda update r-caret
If a new version of a package is available in the R channel, you can use
conda updateto update specific packages.
Creating and sharing custom R bundles#
Creating and sharing custom R bundles is similar to creating and sharing conda packages.
EXAMPLE: Create a simple custom R bundle metapackage named “Custom-R-Bundle” that contains several popular programs and their dependencies:
conda metapackage custom-r-bundle 0.1.0 --dependencies r-irkernel jupyter r-ggplot2 r-dplyr --summary "My custom R bundle"
Share the new metapackage by uploading it to your channel on anaconda.org:
conda install anaconda-client
anaconda upload custom-r-bundle-0.1.0-0.tar.bz2
Anyone can now access your custom R bundle from any computer:
conda install -c <your anaconda.org username> custom-r-bundle
Creating an environment with R#
Create a new conda environment with all the r-essentials conda packages built from CRAN:
conda create -n r_env r-essentials r-base
Activate the environment:
conda activate r_env
List the packages in the environment:
The list shows that the package r-base is installed and r is listed in the build string of the other R packages in the environment.
Anaconda Navigator, the Anaconda graphical package manager and application launcher, creates R environments by default.
Creating a new environment with R#
When creating a new environment, you can use R by explicitly including r-base in your list of packages.
With conda 4.6:
conda create -n r-environment r-essentials r-base
conda activate r-environment
Mirroring the R channel#
Many Enterprise customers maintain a local mirror of the R channel.
When mirroring the R channel for the first time, clean the
existing packages by running the command
anaconda-server-sync-conda with the option
Uninstalling R Essentials#
To uninstall the R Essentials package, run:
conda remove r-essentials
This removes only R Essentials and disables R language support. Other R language packages are not removed.
Here are some additional resources on using Anaconda with the R programming language:
R Language packages available for use with Anaconda–There are hundreds of R language packages now available and several ways to get them.
Navigator tutorial–Use the R programming language with Anaconda Navigator. The Anaconda Navigator graphical interface (GUI) makes it easy for even new users to use and run the R language in a Jupyter Notebook.
Webinar: Anaconda for R Users–Download the slides from the webinar to see how Anaconda makes package, dependency and environment management easy with R language and other Open Data Science languages.