Which version of R is running in my computer?

139,933

Solution 1

Run R --version there's info about version on the first line.

Edit: If you ask this question then I bet that R is not running from any of these directories. Check $PATH env variable to get information where binaries are looked for and in which order.

Edit 2: Use type shell command to find where binary for given command is stored, -a for all paths, -f for the hashed one (basically: most recently used).

Solution 2

05/20/2021 Update:

It should be R.version now


In addition to @Piotr Jaszkowski, R.Version() should do the work as well

Solution 3

The builtin version will show this.

> version
               _                            
platform       x86_64-apple-darwin9.8.0     
...
version.string R version 2.15.2 (2012-10-26)

version is a named list with 14 items, really you just want to see:

> version[['version.string']]
               _                            
[1] "R version 2.15.2 (2012-10-26)"

and in fact if you only want the version-string:

> strsplit(version[['version.string']], ' ')[[1]][3]
[1] "2.15.2"

Type builtins() to see all the builtins.

POSTSCRIPT: turns out version and R.version (mentioned by nathaninmac) are aliases for the same thing.

Solution 4

Try sessionInfo()

Next to the R version it also returns the versions of the loaded packages and more.

http://stat.ethz.ch/R-manual/R-patched/library/utils/html/sessionInfo.html

Solution 5

This will do the trick as well

paste0(R.Version()[c("major","minor")], collapse = ".")
Share:
139,933
showkey
Author by

showkey

Working at high school.

Updated on July 26, 2022

Comments

  • showkey
    showkey almost 2 years

    There are two R directories on my computer:
    one is /home/R-2.15.2,the other is /home/R-2.15.1,
    when I input R , I can start R, now I want to know which R is running: 2.15.1 or 2.15.2?

  • smci
    smci over 6 years
    It might appear simple, but its output is a 14-part formatted string...
  • Hahnemann
    Hahnemann about 5 years
    It's R.version.
  • Ferroao
    Ferroao over 4 years
    or paste0(R.version$major,".",R.version$minor)
  • fdetsch
    fdetsch almost 3 years
    If needed, paste(R.Version()[c("major", "minor")], collapse = ".") gives you the raw version string.
  • Josiah Yoder
    Josiah Yoder almost 3 years
    Following nathaninmac's answer, paste(version[c("major", "minor")], collapse = ".") is another way to get the version string 2.15.2