How to tell which version of R I'm running when two versions are installed

Learn how to tell which version of r i'm running when two versions are installed with practical examples, diagrams, and best practices. Covers r, version, built-in development techniques with visua...

Identifying Your R Version When Multiple Installations Coexist

Identifying Your R Version When Multiple Installations Coexist

Learn how to accurately determine which R version you are currently running, especially when you have multiple R installations on your system. This guide covers built-in R functions and command-line tools.

It's common for R users, especially those working on diverse projects or managing different package dependencies, to have multiple versions of R installed on their machines. This can lead to confusion about which specific R environment is active at any given moment. This article will guide you through various methods to reliably check your current R version, ensuring you're always working with the intended environment.

Checking the R Version from Within R

The most straightforward way to determine your R version is from within an active R session. R provides built-in functions that give you detailed information about the R installation and the session environment. This method is effective whether you're using the R console, RStudio, or any other R IDE.

sessionInfo()

R.version

version

Using sessionInfo(), R.version, and version to get R version details.

Using Command-Line Tools for R Version Detection

Sometimes you might need to check the R version without launching a full R session, perhaps in a script or a terminal. Command-line tools offer a quick and efficient way to do this. This is especially relevant in automated workflows or when troubleshooting environment paths.

R --version

which R

Using R --version to display the R version and which R to locate the R executable.

A flowchart diagram showing the process of identifying the R version. Start with 'Open R Console / Terminal'. Decision 'Within R Session?'. If Yes, 'Run sessionInfo() / R.version'. If No, 'Run R --version / which R'. Both paths lead to 'Identify R Version'. Use blue rectangles for actions, green diamond for decision, and clear arrows for flow.

Flowchart for identifying R version.

Managing Multiple R Installations

For users with several R versions, tools like Renv or conda can help manage and switch between different environments seamlessly. However, even with these tools, understanding how to verify the active R version is crucial for preventing conflicts and ensuring consistent project execution.

1. Step 1

Open your R environment (RStudio, R console, or terminal).

2. Step 2

For an in-depth report, type sessionInfo() and press Enter.

3. Step 3

For a concise version number, type R.version or version and press Enter.

4. Step 4

From the terminal, use R --version to quickly see the active R executable's version.

5. Step 5

To find the exact location of the R executable being used, run which R in your terminal.