.unitConverter | R Documentation |
Convert a data frame to common units
.unitConverter(data, xUnit = NULL, yUnit = NULL)
data |
A data frame (or a tibble) from |
xUnit , yUnit |
Target units for |
toUnit
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.