parse_quantities {quantities} | R Documentation |
Functions to parse character vectors into quantities.
parse_quantities(x, decimal_mark) parse_units(x, decimal_mark) parse_errors(x, decimal_mark)
x |
a character vector to parse. |
decimal_mark |
the dot ( |
Each parse_*()
function returns an object of the corresponding
type, no matter what it is found. This means that, for parse_units
, if
errors are found, they are dropped with a warning. Similarly for
parse_errors
, if units are found, they are dropped with a warning.
On the other hand, parse_quantities
always returns a valid
quantities
object, even if no errors or units are found (then, zero
error and dimensionless units are applied).
A quantities
, units
or errors
object respectively.
parse_quantities("(1.6021766208 +/- .0000000098) e-19 C") parse_quantities("1.6021766208(98) e-19 C") parse_units("1.6021766208 e-19 C") parse_errors("1.6021766208(98) e-19") # quantities are converted to the first unit parse_quantities(c("12.34(2) m/s", "36.5(1) km/h")) # or kept as a list of mixed units parse_quantities(c("1.02(5) g", "2.51(0.01) V", "(3.23 +/- 0.12) m"))