Learn R Programming

tidywater (version 0.7.0)

convert_units: Calculate unit conversions for common compounds

Description

This function takes a value and converts units based on compound name.

Usage

convert_units(value, formula, startunit = "mg/L", endunit = "M")

Value

A numeric value for the converted parameter.

Arguments

value

Value to be converted

formula

Chemical formula of compound. Accepts compounds in mweights for conversions between g and mol or eq

startunit

Units of current value, currently accepts g/L; g/L CaCO3; g/L N; M; eq/L; and the same units with "m", "u", "n" prefixes

endunit

Desired units, currently accepts same as start units

Examples

Run this code
convert_units(50, "ca") # converts from mg/L to M by default
convert_units(50, "ca", "mg/L", "mg/L CaCO3")
convert_units(50, "ca", startunit = "mg/L", endunit = "eq/L")

Run the code above in your browser using DataLab