Kelas S3 sederhana untuk mewakili versi numerik termasuk versi paket, dan metode terkait.
numeric_version(x, strict = TRUE)
package_version(x, strict = TRUE)
R_system_version(x, strict = TRUE)
getRversion()
| Parameter | Deskripsi |
|---|---|
x |
a character vector with suitable numeric version strings (see ‘Details’); for package_version, alternatively an R version object as obtained by R.version. |
strict |
a logical indicating whether invalid numeric versions should results in an error (default) or not. |
# NOT RUN {
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$major
x$minor
if(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 integer
x[[2, 3]] <- 0 # zero the patchlevel
x[[c(2, 3)]] <- 0 # same
x
x[[3]] <- "2.2.3"; x
x <- c(x, package_version("0.0"))
is.na(x)[4] <- TRUE
stopifnot(identical(is.na(x), c(rep(FALSE,3), TRUE)),
anyNA(x))
# }