Learn R Programming

pharmr (version 2.2.0)

convert_unit: convert_unit

Description

Convert between units for a data variable

The conversion could either be handled in the model code or optionally in the dataset (if applicable). Note that when doing the conversion in the model the unit of the data variable itself will not change. The change will affect the unit of relevant parameters in the model.

Note that only ratio units are supported (i.e. not interval scale units like °C).

Usage

convert_unit(model, variable, unit, original_unit = NULL, in_dataset = FALSE)

Value

(Model) Updated Pharmpy model

Arguments

model

(Model) Pharmpy model

variable

(str) Which variable in the dataset or the model code to convert

unit

(str or Unit) The new unit

original_unit

(str or Unit (optional)) If no original unit is available in the datainfo this will be used

in_dataset

(logical) Set to TRUE if the conversion should be done in the dataset instead of in model code

Examples

Run this code
if (FALSE) {
model <- load_example_model("pheno")
model <- convert_unit(model, "WGT", "g")
}

Run the code above in your browser using DataLab