How to use RStudio with R environments#

Note

RStudio and R packages are unavailable on ARM64/AARCH64 CPU architectures. The following instructions are for x86_64 CPU architectures.

Installing RStudio#

  1. Start Navigator.

  2. Click Install on the RStudio application tile.

  3. If Navigator asks you to choose a different environment to install RStudio, name a new environment or choose an existing environment from the dropdown, then click Create. An installation of RStudio installs r-base and many other R packages as dependencies.

Once RStudio is installed, click Launch on the RStudio tile to open it.

Confirming RStudio is connected to your environment#

Using Navigator to install RStudio creates an environment for the application to utilize while you work. Launching the application from Navigator automatically connects the application to the environment created during initial installation.

To verify that RStudio is using the intended environment:

  1. Launch RStudio.

    Caution

    RStudio automatically prompts you to update when launched because Anaconda does not supply you with the latest package versions. Exercise caution when using conda to update RStudio or other R packages to their latest versions. This might break your conda RStudio environment. For more information, see Updating R packages.

  2. Confirm the R library path is correct by running following command in the RStudio console:

    .libPaths()
    
  3. Confirm installed R packages correctly load by running the following command in the RStudio console:

    # Replace <PACKAGE_NAME> with the package you are loading
    library(<PACKAGE_NAME>)
    
    Example

    Load r-dplyr by running the following command in the RStudio console:

    library(dplyr)
    

    The console will display output similar to the following:

    Attaching package: 'dplyr'
    
    The following objects are masked from 'package:stats':
    
        filter, lag
    
    The following objects are masked from 'package:base':
    
        intersect, setdiff, setequal, union
    

Viewing packages in your RStudio environment#

Navigator also installs RStudio’s package dependencies while installing RStudio. This includes r-base and many other R packages.

To view the packages in your RStudio environment:

  1. Open the Environments page.

  2. Select Installed from the dropdown next to Channels.

  3. Search for “r-” in the Search packages box to filter the list of installed packages.

Adding packages to your RStudio environment#

To add new packages to your RStudio environment:

  1. Open the Environments page.

  2. Select Not installed from the dropdown next to Channels.

  3. Search for a package to install, like r-essentials. For more information on r-essentials, see Using R Language with Anaconda.

  4. Select the checkbox next to the package(s) you want to install.

  5. Click Apply.

Updating R packages#

Anaconda’s R packages are not synchronized with the latest CRAN releases. The R packages available for Linux x86_64 are the most current, but are still several versions behind. For more information on updating R packages, see Using R language with Anaconda.

Caution

Exercise caution when using conda to update RStudio or other R packages to their latest versions. This might break your conda RStudio environment.