View source: R/utilities-units.R
toUnit | R Documentation |
Converts a value given in base unit of a quantity into a target unit
toUnit(
quantityOrDimension,
values,
targetUnit,
sourceUnit = NULL,
molWeight = NULL,
molWeightUnit = NULL
)
quantityOrDimension |
Instance of a quantity from which the dimension will be retrieved or name of dimension |
values |
Values to convert (single or vector). If |
targetUnit |
Unit to convert to |
sourceUnit |
Optional Name of the unit to convert from. If |
molWeight |
Optional molecular weight to use when converting, for example, from molar to mass amount or concentration. If |
molWeightUnit |
Optional Unit of the molecular weight value. If |
simPath <- system.file("extdata", "simple.pkml", package = "ospsuite")
sim <- loadSimulation(simPath)
par <- getParameter("Organism|Liver|Volume", sim)
# Converts the value in base unit (1L) to ml => 1000
valueInMl <- toUnit(par, 1, "ml")
valuesInMl <- toUnit(par, c(1, 5, 5), "ml")
# Converts a numerical value in from mmol/l to mg/dl
valuesInMgDl <- toUnit(ospDimensions$`Concentration (molar)`, 5,
targetUnit = "mmol/l",
sourceUnit = "mg/dl", molWeight = 180, molWeightUnit = "g/mol"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.