dot-unitConverter: Convert a data frame to common units

.unitConverterR Documentation

Convert a data frame to common units

Description

Convert a data frame to common units

Usage

.unitConverter(data, xUnit = NULL, yUnit = NULL)

Arguments

data

A data frame (or a tibble) from DataCombined$toDataFrame().

xUnit, yUnit

Target units for xValues and yValues, respectively. If not specified (NULL), first of the existing units in the respective columns (xUnit and yUnit) will be selected as the common unit. For available dimensions and units, see ospsuite::ospDimensions and ospsuite::ospUnits, respectively.

See Also

toUnit

Examples


# small dataframe to illustrate the conversion
(df <- dplyr::tibble(
  dataType = c(rep("simulated", 3), rep("observed", 3)),
  xValues = c(0, 14.482, 28.965, 0, 1, 2),
  xUnit = "min",
  xDimension = "Time",
  yValues = c(1, 1, 1, 1, 1, 1),
  yUnit = c("mol", "mol", "mol", "g", "g", "g"),
  yDimension = c("Amount", "Amount", "Amount", "Mass", "Mass", "Mass"),
  yErrorValues = c(2.747, 2.918, 2.746, NA, NA, NA),
  yErrorUnit = c("mol", "mol", "mol", "g", "g", "g"),
  molWeight = c(10, 10, 20, 20, 20, 10)
))

# default conversion
ospsuite:::.unitConverter(df)

# customizing conversion with specified unit(s)
ospsuite:::.unitConverter(df, xUnit = ospUnits$Time$h)
ospsuite:::.unitConverter(df, yUnit = ospUnits$Mass$kg)
ospsuite:::.unitConverter(df, xUnit = ospUnits$Time$s, yUnit = ospUnits$Amount$mmol)

Open-Systems-Pharmacology/OSPSuite-R documentation built on Feb. 14, 2025, 4:48 p.m.