Learn R Programming

apsimx (version 2.2)

unit_conv: performs common unit conversions

Description

This function is slowly getting better. Adding more unit conversions as I need them.

Usage

unit_conv(x, from, to, ...)

Arguments

x

input variable

from

original units

to

target units

...

additional arguments passed to specific conversions

Value

value of the input variable with new units

Details

Function which performs common unit conversions

At the moment possible conversions are:

  • ‘g/m2’ to ‘kg/ha’

  • ‘kg/ha’ to ‘g/m2’

  • ‘lb’ to ‘kg’

  • ‘kg’ to ‘lb’

  • ‘maize bu’ to ‘kg’

  • ‘kg’ to ‘maize bu’

  • ‘soy bu’ to ‘kg’

  • ‘kg’ to ‘soy bu’

  • ‘maize bu/ac’ to ‘kg/ha’

  • ‘maize bu/ac’ to ‘g/m2’

  • ‘kg/ha’ to ‘maize bu/ac’

  • ‘g/m2’ to ‘maize bu/ac’

  • ‘soy bu/ac’ to ‘kg/ha’

  • ‘soy bu/ac’ to ‘g/m2’

  • ‘kg/ha’ to ‘soy bu/ac’

  • ‘g/m2’ to ‘soy bu/ac’

  • ‘mm’ to ‘inches’

  • ‘inches’ to ‘mm’

  • ‘lb/ac’ to ‘kg/ha’

  • ‘kg/ha’ to ‘lb/ac’

  • ‘lb/ac’ to ‘g/m2’

  • ‘g/m2’ to ‘lb/ac’

  • ‘decimal’ to ‘degrees’

  • ‘degrees’ to ‘decimal’

This is for metric and Imperial conversions Source: https://www.extension.iastate.edu/agdm/wholefarm/html/c6-80.html

Examples

Run this code
# NOT RUN {
grain.yield.gm2 <- 600
grain.yield.kgha <- unit_conv(grain.yield.gm2, from = "g/m2", to = "kg/ha")
grain.yield.kgha
## Converting coordinates
require(sp)
unit_conv("42d 0' 0\" N", from = "degrees", to = "decimal")
unit_conv(42, from = "decimal", to = "degrees") ## EW by default
unit_conv(42, from = "decimal", to = "degrees", NS = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab