This converts strings to unit objects. Only a few strings are recognized, because most oce functions have specialized unit vocabularies and so have little need of this function.
as.unit(u, default = list(unit = expression(), scale = ""))
A character string indicating a unit. Case is ignored, so that e.g.
"dbar"
and "DBAR"
yield equal results. The following are recognized:
c("m-1"
, "dbar"
, "decibar"
, "degree"
, "degree_Celcius"
,
"degree_north"
, "degree_east"
, "ipts-68"
,
"its-90"
, "m/s^1"
, "m/s^2"
, "pss-78"
,
"umol/kg"
, "micromole/kg"
)
A default to be used for the return value, if u
is not a recognized string.
A list with elements unit
, an expression()
,
and scale
, a string.
as.unit("DBAR")
#> $unit
#> expression(dbar)
#>
#> $scale
#> [1] ""
#>
as.unit("IPTS-68")
#> $unit
#> expression(degree * C)
#>
#> $scale
#> [1] "IPTS-68"
#>
as.unit("ITS-90")
#> $unit
#> expression(degree * C)
#>
#> $scale
#> [1] "ITS-90"
#>
as.unit("PSS-78")
#> $unit
#> expression()
#>
#> $scale
#> [1] "PSS-78"
#>
as.unit("UMOL/KG")
#> $unit
#> expression(mu * mol/kg)
#>
#> $scale
#> [1] ""
#>