units: Unit conversions via the system GNU "units" command

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This routine will do unit conversions based on the GNU “Units” command (see References section). Any conversions that are legal there will work here.

Usage

1
Units(x = c(3, 5), from = c("m"), to = "ft")

Arguments

x

a vector of quantities in the from units to convert from

from

a vector of units that apply to x; if scalar, it will be repeated to the length of x

to

a vector of units that we want x converted to; it will be recycled as above

Details

See examples below, just make sure things are compatible with the GNU “Units” command. If any unit conversions are illegal, it will throw an error. It does not do much checking beyond this, so it will take whatever is given to it. This works flawlessly on Linux, and may be installed with dnf (Red Hat/Fedora and derivatives) or the system package manager. It requires downloading and installing GNU “Units” on other operating systems (see below).

Value

A data frame with the first column the actual command that can be used in system, the second column contains the original quantities x to be converted, and the third column holds the conversions asked for.

Note

The routine uses a capital “U” because it was conflicting with the units command in R's base package.

Author(s)

JHG

References

Please see http://www.gnu.org/software/units/units.html information about units and its use (and installation on other systems).

See Also

system

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#
# okay to run if you have GNU units installed...
#
## Not run: 
Units(1,'m','ft')                              #simple conversion factor
Units(c(25,50),'m^2/hectare','ft^2/acre')      #basal area quantities
Units(c(250,500),'ft^3/acre','m^3/hectare')    #volume quantities
Units(c(250,1,1),c('ft^3/acre','acre','hectare'),c('m^3/hectare','hectare','acre')) #mixture

## End(Not run)

Mensuration documentation built on May 2, 2019, 4:52 p.m.