Description Usage Arguments Details Value Note Author(s) References See Also Examples
This routine will do unit conversions based on the GNU “Units” command (see References section). Any conversions that are legal there will work here.
1 |
x |
a vector of quantities in the |
from |
a vector of units that apply to |
to |
a vector of units that we want |
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).
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.
The routine uses a capital “U” because it was conflicting
with the units
command in R's base package.
JHG
Please see http://www.gnu.org/software/units/units.html
information about units
and its use (and installation on other systems).
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.