RDocumentation: R.Version
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.

    if(!require('base')) {
        install.packages('base')
        library('base')
    }
    require(graphics)
    
    R.version$os # to check how lucky you are ...
    plot(0) # any plot
    mtext(R.version.string, side = 1, line = 4, adj = 1) # a useful bottom-right note
    
    ## a good way to detect macOS:
    if(grepl("^darwin", R.version$os)) message("running on macOS")
    
    ## Short R version string, ("space free", useful in file/directory names;
    ##                          also fine for unreleased versions of R):
    shortRversion <- function() {
       rvs <- R.version.string
       if(grepl("devel", (st <- R.version$status)))
           rvs <- sub(paste0(" ",st," "), "-devel_", rvs, fixed=TRUE)
       gsub("[()]", "", gsub(" ", "_", sub(" version ", "-", rvs)))
    }
    shortRversion()