How-To: Using Anaconda - Install an R Package in a Virtual Conda Environment via Command Line Interface

Summary

Install an R package from CRAN in a virtual conda environment using the command line interface.

Body

Question

How do I install R packages in a virtual conda environment via command line interface?

 

Answer

Note:  To add a channel to top of list from the command line, see "How-To: Using Anaconda - Add Channel to Top of List in a Virtual Conda Environment via Command Line Interface

1. From the Anaconda Prompt command line (CLI) in an active virtual conda environment, enter "conda config --show channels" to list channels in order of priority.

  • This will ensure the conda-forge channel is the top of the channel list in the environment. 
  • Using the conda-forge channel will ensure the R package and dependencies will come from the CRAN repository.

Command prompt with listed channels, conda-forge highlighted

 

Note:  To activate an environment from the command line, see "How-To: Using Anaconda - Activate a Virtual Conda Environment via Command Line Interface"

2. Add new R package.

a. Enter "conda install r-<package-name>" to install package.The below screenshots show the beginning and end output of installation of the example R package.

Example package: dplyr 

b. A prompt to proceed will be displayed and require entering "y".

c. The new package is added.

command line, command "conda install r-dplyr"

Prompt to proceed with installation.

 

Details

Details

Article ID: 2368
Created
Wed 5/6/26 2:20 PM
Modified
Tue 5/12/26 10:39 AM

Related Articles

Related Articles (7)

Install a Package in a Conda Environment via Command Line Interface
Install a PyPI Package with PIP in a Conda Environment via Command Line Interface
Remove a Package in a Conda Environment via Command Line Interface.
Update a Package in a Conda Environment via Command Line Interface
Update all Packages in a Conda Environment via Command Line Interface
Upgrade a PyPI Package with PIP in a Conda Environment via Command Line Interface
Index of Miniconda How-To Articles for Virtual Conda Environments