knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
{versionr} is a lightweight package designed to remove the friction of working
with version numbers in R. The main benefit of versionr
is the
vctrs-powered S3 class version_number
.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("wurli/versionr")
Version numbers can be created using characters or numeric vectors, and can have arbitrary numbers of parts
library(versionr) version_number("1.0.0", "1.0.1") version_number(c(1, 0, 0, 0), c(1, 0, 0, 1))
A main benefit of {versionr} is easy version comparison and sorting
nums <- version_number("1.0.0", "1.0.11", "1.0.2", "2.0.0.1") # 1.0.11 should come after 1.0.2: nums[2] > nums[3] # Sorting is easy: sort(nums)
Version numbers can be easily 'bumped' using bump_version()
:
bump_version(nums, "patch") bump_version(nums, "major")
Version numbers are vectors, and you can easily access particular parts using
version_part()
:
version_part(nums, "minor") version_part(nums, "dev")
Behind the scenes, version numbers are just vectors of integers wrapped in a list:
unclass(nums)
...This makes intuitive subsetting possible:
nums[[3]][4]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.