View source: R/utilities-data-combined.R
convertUnits | R Documentation |
DataCombined
to common unitsWhen multiple (observed and/or simulated) datasets are present in a data frame, they are likely to have different units. This function helps to convert them to a common unit specified by the user.
This is especially helpful while plotting since the quantities from different datasets to be plotted on the X-and Y-axis need to have same units to be meaningfully compared.
convertUnits(dataCombined, xUnit = NULL, yUnit = NULL)
dataCombined |
A single instance of |
xUnit , yUnit |
Target units for |
A data frame with measurement columns transformed to have common units.
In the returned tibble data frame, the following columns will always be present:
name - group - dataType - xValues - xDimension - xUnit - yValues - yErrorValues - yDimension - yUnit - yErrorType - yErrorUnit - molWeight
Importantly, the xUnit
and yUnit
columns will have unique entries.
Molecular weight is required for the conversion between certain
dimensions (Amount
, Mass
, Concentration (molar)
, and Concentration (mass)
). Therefore, if molecular weight is missing for these dimension, the
unit conversion will fail.
Other data-combined:
DataCombined
,
calculateResiduals()
# simulated data
simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite")
sim <- loadSimulation(simFilePath)
simResults <- runSimulations(sim)[[1]]
outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)"
# observed data
obsData <- lapply(
c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"),
function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite"))
)
names(obsData) <- lapply(obsData, function(x) x$name)
# Create a new instance of `DataCombined` class
myDataCombined <- DataCombined$new()
# Add simulated results
myDataCombined$addSimulationResults(
simulationResults = simResults,
quantitiesOrPaths = outputPath,
groups = "Aciclovir PVB"
)
# Add observed data set
myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB")
convertUnits(
myDataCombined,
xUnit = ospUnits$Time$s,
yUnit = ospUnits$`Concentration [mass]`$`µg/l`
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.