convert_values: Convert values to different units

View source: R/units.R

convert_valuesR Documentation

Convert values to different units

Description

Convert values to different units

Usage

convert_values(x, from, to, messages)

Arguments

x

a numeric vector of values to convert

from

units to convert from

to

units to convert to

messages

should messages be printed when

Details

Currently supported units for from and to are: c("ng/L", "ug/L", "mg/L", "g/L", "kg/L", "pH", "degC", "C", "CFU/dL", "MPN/dL", "CFU/100mL", "MPN/100mL", "CFU/g", "MPN/g", "CFU/mL", "MPN/mL", "Col.unit", "Rel", "NTU", "m", "uS/cm")

Value

a numeric vector of the converted values

Examples


convert_values(1, "ug/L", "mg/L", messages = FALSE)

df <- data.frame(
  value = c(1.256, 5400000, 12300, .00098),
  units = c("mg/L", "ng/L", "ug/L", "g/L"),
  stringsAsFactors = FALSE
)
df

df$units_mg_L <- convert_values(df$value, from = df$units, to = "mg/L", messages = FALSE)
df

bcgov/wqbc documentation built on Feb. 11, 2023, 11:15 p.m.