Converts a value given in base unit of a quantity into a target unit

## Usage

toUnit(
quantityOrDimension,
values,
targetUnit,
sourceUnit = NULL,
molWeight = NULL,
molWeightUnit = NULL
)

## Arguments

quantityOrDimension

Instance of a quantity from which the dimension will be retrieved or name of dimension

values

Values to convert (single or vector). If sourceUnit is not specified, values are in the base unit of the dimension

targetUnit

Unit to convert to

sourceUnit

Optional Name of the unit to convert from. If NULL (default), the values are assumed to be in base unit.

molWeight

Optional molecular weight to use when converting, for example, from molar to mass amount or concentration. If molWeightUnit is not specified, molWeight is assumed to be in kg/µmol

molWeightUnit

Optional Unit of the molecular weight value. If NULL (default), kg/µmol is assumed.

## Examples

simPath <- system.file("extdata", "simple.pkml", package = "ospsuite")
valuesInMgDl <- toUnit(ospDimensions\$Concentration (molar), 5,