| numeric_version | R Documentation |
A simple S3 class for representing numeric versionsincluding package versions, and associated methods.
numeric_version(x, strict = TRUE)package_version(x, strict = TRUE)R_system_version(x, strict = TRUE)getRversion()
x | a character vector with suitable numeric version strings (see‘Details’); for |
strict | a logical indicating whether invalid numeric versionsshould results in an error (default) or not. |
Numeric versions are sequences of one or more non-negative integers,usually (e.g., in package ‘DESCRIPTION’ files) represented ascharacter strings with the elements of the sequence concatenated andseparated by single. or- characters.R packageversions consist of at least two such integers, anR system versionof exactly three (major, minor and patchlevel).
Functionsnumeric_version,package_version andR_system_version create a representation from such strings (ifsuitable) which allows for coercion and testing, combination,comparison, summaries (min/max), inclusion in data frames,subscripting, and printing. The classes can hold a vector of suchrepresentations.
getRversion returns the version of the runningR as an Rsystem version object.
The[[ operator extracts or replaces a single version. Toaccess the integers of a version use two indices: see the examples.
compareVersion;packageVersion for the version of a specificR package.R.version etc for the version ofR (and the informationunderlyinggetRversion()).
x <- package_version(c("1.2-4", "1.2-3", "2.1"))x < "1.4-2.3"c(min(x), max(x))x[2, 2]x$majorx$minorif(getRversion() <= "2.5.0") { ## work around missing feature cat("Your version of R, ", as.character(getRversion()), ", is outdated.\n", "Now trying to work around that ...\n", sep = "")}x[[c(1, 3)]] # '4' as a numeric vector, same as x[1, 3]x[1, 3] # 4 as an integerx[[2, 3]] <- 0 # zero the patchlevelx[[c(2, 3)]] <- 0 # samexx[[3]] <- "2.2.3"; xx <- c(x, package_version("0.0"))is.na(x)[4] <- TRUEstopifnot(identical(is.na(x), c(rep(FALSE,3), TRUE)), anyNA(x))Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
