Get data from quantity objects including their values (equivalent of as.numeric) and text representations (equivalent of as.character).
get_qty_value(x, unit = NULL) # S3 method for mk_quantity as.double(x, unit = NULL, ...) get_qty_text(x, unit = get_qty_units(x), signif = 5) # S3 method for mk_quantity as.character(x, unit = get_qty_units(x), signif = 5, ...) get_qty_text_each(x, signif = 5)
x | quantities |
---|---|
unit | which units to retrieve quantity data in (by default the unit the quantity is in) |
... | additional parameters for the generics |
signif | number of significant digits for printing the quantity |
get_qty_value
: get the value of a quantity in the desired unit. By default returns the quantity in the units it is in. Functionally equivalent to as.numeric
and as.double
.
as.double.mk_quantity
: S3 extension of as.numeric
and as.double with optional unit
argument
get_qty_text
: get the value of the quantity in the desired unit as a text string with the unit appended. Functionally equivalent to as.character
.
as.character.mk_quantity
: S3 implementation of as.character
with optional unit
and signif
argument
get_qty_text_each
: get each value of a quantity in the best metric unit with the unit appended. Note that if a value is zero, it will use the unit of the next smallest value for this number.
Other quantity functions:
check_quantities
,
make_qty_units_explicit()
,
metric_scaling
,
quantities
,
quantity_units
#> [1] 100#> [1] 0.1#> [1] 32#> [1] 1#> [1] 1#> [1] "100 mg"#> [1] "0.1 g"#> [1] "32 F" "33.8 F" "35.6 F" "37.4 F" "39.2 F" "41 F" "42.8 F" "44.6 F" #> [9] "46.4 F" "48.2 F" "50 F"#> [1] "1 atm"#> [1] "1 atm"#> [1] "0 mg" "0.1 mg" "10 mg" "1000 mg"#> [1] "0 µg" "100 µg" "10 mg" "1 g"