Package 'convertr'

Title: Convert Between Units
Description: Provides conversion functionality between a broad range of scientific, historical, and industrial unit types.
Authors: Gordon Shotwell [aut, cre]
Maintainer: Gordon Shotwell <[email protected]>
License: MIT + file LICENSE
Version: 0.1
Built: 2024-10-26 03:24:40 UTC
Source: https://github.com/gshotwell/convertr

Help Index


Conversion factors for various units

Description

This table provides the conversion factors for convert. The conversion factor is broken into four componts: A, B, C, and D. Units are converted from the origin unit (X) to the respective SI base unit (BU) using the following formula:

BU=(A+BX)/(C+DX)BU = (A + B*X) / (C + D*X)

The data orginates from the POSC Units of Measure Dictionary v2.2 and Wikipedia

Usage

conversion_table

Format

A data frame with 1511 rows and 11 variables:

  • name: Name of the origin unit

  • quantity_type: Description of what the unit is used to measure

  • catalog_name: Origin of unit specification

  • catelog_symbol: Symbol for the unit

  • rp66_symbol: Recomended Practice 66 unit

  • base_unit: Equivalent System Internationale (SI) base unit

  • a: Conversion factor

  • b: Conversion factor

  • c: Conversion factor

  • d: Conversion factor

  • multi_unit: Can the unit be converted to other units?


Convert from one unit type to another

Description

Converts numeric vectors from one unit to another Approximately 1500 units are available. convert_gadget can help you build valid convert() expressions and explore_units provides an interface for exploring the conversion_table which underlies the computation.

Usage

convert(vector, origin, target)

Arguments

vector

A numeric vector to be converted

origin

The catalog symbol of the current unit.

target

The catalog symbol of unit you want to convert to.

Value

A numeric vector

Examples

convert(1:20, "kg", "g")
convert(1:20, "galUK/min.ft2", "kft/s")
## Not run: 
convert(1:20, "kg", "km2")

## End(Not run)

Launch interactive conversion gadget

Description

It's often difficult to remember the symbol for the units you want to convert.This gadget shows which units can be converted to one anohter, and provides an example calculation on a sample vector On exit you can either return a valid convert() call or a converted numeric vector.

Usage

convert_gadget(vector, return_value = FALSE)

Arguments

vector

A numeric vector to convert. You can change the vector within the app.

return_value

By default the gadget generates a convert() call, if return_value is set to TRUE it will instead generate a converted vector.

Value

Insert output text into editor.

Examples

## Not run: 
convert_gadget()
convert_gadget(mtcars$mpg)

## End(Not run)

convertr

Description

convertr allows you to convert numeric vectors between various unit types.


Explore conversion table

Description

A shiny application that lets you take a look at the conversion_table dataframe.

Usage

explore_units()

Value

Launches a Shiny app

Examples

## Not run: 
explot_units()
## End(Not run)

Return the conversion table

Description

A convenience function to return conversion_table

Usage

get_conversion_table()

Value

Conversion table dataframe

Examples

a <-  get_conversion_table()