Description Usage Arguments Details Value See Also Examples
Calculate a factor to convert concentration "A" into concentration "B".
1 2 | calc_factor_conc(from, to, molar_mass = 0, density_solute = 0,
density_solution = 0)
|
from |
A string containing the units of concentration A. |
to |
A string containing the units of concentration B. |
molar_mass |
The molar mass of the solute (g / mol). |
density_solute |
The density of the solute (g / l). |
density_solution |
The density of the solution (g / l), not the solvent! |
The following concentrations can be converted:
mass / volume: ".g / .l", ".g / .m^3", "% w / v"
molar / volume: ".M", ".mol / .l", ".mol / .m^3"
volume / volume: ".l/.l", ".l / m^3", ".m^3/.m^3", ".m^3 / .l", "% v / v", "v / v"
mass / mass: ".g / .g", "w / w", "% w / w"
Where "." symbolizes a metric prefix (see calc_factor_prefix()
) :
For g, l, mol and M: d (deci), c (centi), m (milli), ยต (micro), n (nano), p (pico) and f (femto).
For g you might use k (kilo) as well.
For m^3 (cubic metres) you may only use: d (deci), c (centi) and m (milli).
Note: % w / v is (incorrectly) taken as a short hand for 0.1 g / l.
The factor to convert A into B.
Other conversion functions: calc_factor_prefix
,
convert_conc
, convert_prefix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | library("dplyr")
# generate test data
data <- tibble(
sample = c("A", "B", "C"),
conc = c(4.5, 2.3, 5.1), # concentration in g / l
)
fctr_ng_ml <- calc_factor_conc(from = "g/l", to = "ng/ml")
# give molar mass in g / mol
fctr_mol_l <- calc_factor_conc(from = "g/l", to = "M", molar_mass = 78.971)
# give densities in g / l
fctr_pc <- calc_factor_conc(from = "g/l", to = "%v/v", density_solute = 4810)
data %>%
mutate(
conc_ng_ml = conc * fctr_ng_ml,
conc_mol_l = conc * fctr_mol_l,
conc_pc = conc * fctr_pc
)
# throws an error
## Not run:
# will throw an error because molar_mass is missing
fctr_fail <- calc_factor_conc(from = "g/l", to = "mol/l")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.