Giter Club home page Giter Club logo

units's Introduction

Measurement Units for R

Build Status Coverage Status License CRAN Downloads

Support for measurement units in R vectors, matrices and arrays: automatic propagation, conversion, derivation and simplification of units; raising errors in case of unit incompatibility. Compatible with the POSIXct, Date and difftime classes. Uses the UNIDATA udunits library and unit database for unit compatibility checking and conversion.

Documentation

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 units vignette derives from this manuscript and is kept up to date with the package development.

What it does

Package units provides measurement 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 5
spd1 + spd2                   # automatic conversion
# Units: m/s
# [1] 1.277778 2.555556 3.833333 5.111111 6.388889
spd1 * spd2                   # unit derivation
# Units: km*m/h/s
# [1]  1  4  9 16 25
spd1 * set_units(10, s) # unit simplification
# Units: m
# [1] 10 20 30 40 50
spd1 + set_units(10, s) # error checking
#   cannot convert s into m/s

Installation

Install the release version from CRAN:

install.packages("units")

The installation of the development version from GitHub requires, e.g., the remotes 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-dev

on CentOS7 with

sudo yum install udunits2-devel

or on MacOS with

brew install udunits

or equivalent in your distribution. Alternatively, install it from the sources by downloading udunits-2.2.20.tar.gz from ftp://ftp.unidata.ucar.edu/pub/udunits/, and executing the following commands in the download directory:

tar zxf udunits-2.2.20.tar.gz
cd ./udunits-2.2.20/
./configure
make
sudo make install
sudo ldconfig

Then, retry the installation of units.

units's People

Contributors

edzer avatar enchufa2 avatar mailund avatar t-kalinowski avatar krlmlr avatar lewinfox avatar gmp216 avatar billdenney avatar jeroen avatar kendonb avatar lionel- avatar langmm avatar mjwoods avatar bart1 avatar cregouby avatar yasirs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.