Skip to contents

Helper function to return your system's installed R version in a variety of commonly used formats.

See the format parameter for available options.

Usage

rver(format = c("full", "text", "lib", "major", "minor", "nickname"))

Arguments

format

Character string of one of the following: full, text, lib, major, minor, nickname. See details for specifics.

Value

character string in specified format

Details

The following formatted return values can be specified with the format argument:

  • full: returns the full {major}.{minor}.{patch} semantic version of R.

  • text: returns the version string of R in the format "R version {major}.{minor}.{patch} ({date} {crt})".

  • lib: returns {major}.{minor} R version string; useful for your .libPaths().

  • major: returns only the major R version.

  • minor: returns only the minor R version.

  • nickname: returns the R version's nickname (i.e. the value listed on startup).

Examples

library(configR)

# get full R version
rver()
#> [1] "4.2.0"

# get path the default library path
r_config_dir("lib", rver("lib"))
#> Warning: path[1]="/home/runner/.config/R": No such file or directory
#> Warning: path[1]="/home/runner/.config/R/lib/4.2": No such file or directory
#> [1] "/home/runner/.config/R/lib/4.2"

# get full text string of R version details
rver("text")
#> [1] "R version 4.2.0 (2022-04-22)"