convert_unit: convert_unit

View source: R/functions_wrapper.R

convert_unitR Documentation

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).

Usage

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

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

Value

(Model) Updated Pharmpy model

Examples

## Not run: 
model <- load_example_model("pheno")
model <- convert_unit(model, "WGT", "g")

## End(Not run)


pharmr documentation built on May 28, 2026, 5:08 p.m.