grapes-f-greater-than-grapes: Function pipe for nm objects

%f>%R Documentation

Function pipe for nm objects

Description

[Experimental]

Pipe an nm object object to a list of functions. Although this enables multiple NONMEM runs to be handled simultaneously, it does make your code less readable.

Usage

lhs %f>% rhs

Arguments

lhs

An nm object.

rhs

A list of functions. Must be same length as lhs.

Value

A modified nm object.

See Also

child() for creating multiple child NONMEM objects

Examples


# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1", 
             based_on = file.path(exdir, "Models", "ADVAN2.mod"),
             data_path = file.path(exdir, "SourceData", "THEOPP.csv"))
             
temp_data_file <- paste0(tempfile(), ".csv")

## dataset has missing WTs so create a new one and assign this to the run
input_data(m1) %>% 
  dplyr::group_by(ID) %>%
  dplyr::mutate(WT = na.omit(WT)) %>%
  write_derived_data(temp_data_file)
  
m1 <- m1 %>% data_path(temp_data_file)

mWT <- m1 %>% child(c("m2", "m3", "m4")) %f>% 
list(
 . %>% add_cov(param = "V", cov = "WT", state = "linear"),
 . %>% add_cov(param = "V", cov = "WT", state = "power"),
 . %>% add_cov(param = "V", cov = "WT", state = "power1")
)

mWT %>% dollar("PK")

unlink(temp_data_file)


tsahota/NMproject documentation built on Oct. 1, 2022, 11:51 a.m.