Using R language with Anaconda
With Anaconda (or Miniconda), you can 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, add r-
before the regular package name. For instance, to install rbokeh, use conda install r-rbokeh
. To install rJava, use conda install r-rjava
.
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.
The version of the R interpreter installed into your R environments is based on the version of the r-base
package.
Run the commands in the following sections in Anaconda Prompt (Terminal on macOS/Linux).
Updating R packages
Exercise caution when using conda to update RStudio or other R packages to their latest versions. This might break your conda RStudio environment.
-
Update all of the packages and their dependencies by running the following command:
-
If a new version of a package is available in the R channel, update specific packages by running the following command:
Creating and sharing custom R bundles
Creating and sharing custom R bundles is similar to creating and sharing conda packages. In the following example, we will create a simple custom R bundle metapackage named “Custom-R-Bundle”.
-
Create the metapackage “Custom-R-Bundle” that contains several popular programs and their dependencies by running the following command:
-
Upload the new metapackage to your channel on anaconda.org by running the following commands:
Anyone can now access your custom R bundle from any computer by running the following command:
Creating an environment with R
-
Create a new conda environment with all the
r-essentials
conda packages built from CRAN by running the following command: -
Activate the environment by running the following command:
-
List the packages in the environment by running the following command:
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.
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:
Uninstalling R Essentials
Uninstall the R Essentials package by running the following command:
This removes only R Essentials and disables R language support. Other R language packages are not removed.
Resources
Hundreds of R Language packages are available for use with Anaconda with several ways to get them.
Was this page helpful?