- Notifications
You must be signed in to change notification settings - Fork34
Measurement units for R
r-quantities/units
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Support for measurement units in R vectors, matricesand arrays: automatic propagation, conversion, derivationand simplification of units; raising errors in case of unitincompatibility. Compatible with the POSIXct, Date and difftimeclasses. Uses the UNIDATA udunits library and unit database forunit compatibility checking and conversion.
Documentation is provided in an R Journal publication. Cite this package as:
- Edzer Pebesma, Thomas Mailund and James Hiebert (2016). "Measurement Units in R."The R Journal, 8 (2), 486--494.DOI:10.32614/RJ-2016-061
The main unitsvignettederives from this manuscript and is kept up to date with the package development.
Packageunits providesmeasurement units for R vectors: conversion, derivation, simplification and error checking:
library(units)(spd1= set_units(1:5,m/s))# Units: m/s# [1] 1 2 3 4 5(spd2= set_units(1:5,km/h))# Units: km/h# [1] 1 2 3 4 5spd1+spd2# automatic conversion# Units: m/s# [1] 1.277778 2.555556 3.833333 5.111111 6.388889spd1*spd2# unit derivation# Units: km*m/h/s# [1] 1 4 9 16 25spd1* set_units(10,s)# unit simplification# Units: m# [1] 10 20 30 40 50spd1+ set_units(10,s)# error checking# cannot convert s into m/s
Install the release version from CRAN:
install.packages("units")The installation of the development version from GitHub requires, e.g., theremotes package:
remotes::install_github("r-quantities/units")
If the installation fails due to a missing udunits2 system library, either install it e.g. on Ubuntu or Debian by
sudo apt-get install libudunits2-devon Fedora or RHEL/CentOS with
sudo dnf install udunits2-develor on MacOS with
brew install udunitsor equivalent in your distribution. Alternatively, install it from the sources by downloading the latest version fromUDUNITS downloads, and executing the following commands in the download directory:
tar zxf udunits-<version>.tar.gzcd ./udunits-<version>/./configuremakesudo make installsudo ldconfigThen, retry the installation ofunits.
About
Measurement units for R
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.