An R package to convert volume measurements to crans.
What’s a cran? It’s a unit of uncleaned herring. It has nothing to do with the Comprehensive R Archive Network (CRAN).
The package depends on the {units} package (site, source, R Journal) for unit conversions.
Read more in the blog post.
Assuming you've installed {remotes} and you’re an 18th Century
fisherman, install with remotes::install_github("matt-dray/cran")
.
On load, you’re asked if you want to create the cran unit. Type yes
and units::install_conversion_constant()
will generate the
unit ready for you to use in your workspace.
library(cran)
# Create the 'cran' unit of measurement for this session? yes/no: yes
# You're ready to measure uncleaned herring.
Let’s confirm that 170.5 litres is a cran:
cran_convert(value = 170.5, unit = "L")
# 1 [cran]
How many crans in 10 pints?
cran_convert(value = 10, unit = "pint")
# 0.002775229 [cran]
We can use {units} to convert the other way as well. How many cubic centimetres in a cran?
one_cran <- units::as_units(1, "cran")
units::set_units(one_cran, "cc")
# 170500 [cc]
You can remove the cran unit at any time with cran_remove()
. To reinstall it, use cran_install()
.