programmatically find the current version of R

In R, you can determine the version of a particular package and use the relational operators on it with packageVersion() . For instance:

 packageVersion("MASS") (pp <- packageVersion("MASS")) ## [1] '7.3.43' pp > '7.2.0' ## TRUE 

How to get the equivalent form of version information for the current copy of R itself?

To answer this question, you need to determine exactly where to look, which is not as simple as it seems: for example

 grep("R[._vV]",apropos("version"),value=TRUE) ## [1] ".ess.ESSRversion" ".ess.Rversion" "getRversion" ## "R_system_version" ## [5] "R.Version" "R.version" "R.version.string" 

I ask this because I'm upset that I need to sort it out every few months ... I will answer if no one does this. Extra credit to find out the difference between packageVersion() and package_version() ...

I think that this question will be answered here , but the focus of my question will be specifically how to get information in a program form (i.e. not only how to find out which version works, but also how to get it in a form suitable to run automatic version tests inside R).

+5
source share
2 answers

They are described on the ?R.Version help page. It depends on how you want the value to be formatted / saved in reality.

packageVersion() extracts version information from a specific package as a package_version object.

package_version() essentially parses the version number into a package_version value that can be easily compared.

You can compare versions with

 package_version(R.version) > package_version("3.0.1") 

or something like that.

The getRversion() function specified in the ?R.Version help page automatically returns a package_version object.

 getRversion() > package_version("3.0.1") 

In addition, package_version objects package_version also perform automatic conversion with matching strings.

 getRversion() > "3.0.1" 
+6
source

AFAIK, the constant constant gives you this information. In my case:

 version ## platform x86_64-pc-linux-gnu ## arch x86_64 ## os linux-gnu ## system x86_64, linux-gnu ## status ## major 3 ## minor 2.2 ## year 2015 ## month 08 ## day 14 ## svn rev 69053 ## language R ## version.string R version 3.2.2 (2015-08-14) ## nickname Fire Safety with(version, paste(major, minor, sep='.')) ## [1] "3.2.2" 
+2
source

All Articles