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

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)
#> written: 
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmprG2vBv/file8db6b931c68.RDS
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmprG2vBv/file8db6b931c68.csv
  
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")
#> $`execute.Models/m2`
#>   1| $PK
#>   2| 
#>   3| ;;; TVVWT-DEFINITION START
#>   4| TVVWT= ( 1 + THETA(4)*(WT - 70.5))
#>   5| ;;; TVVWT-DEFINITION END
#>   6| 
#>   7| ;;; TVV-RELATION START
#>   8| TVVCOV=TVVWT
#>   9| ;;; TVV-RELATION END
#>  10| 
#>  11| TVKA=EXP(THETA(1))
#>  12| MU_1=LOG(TVKA)
#>  13| KA = EXP(MU_1+ETA(1))
#>  14| 
#>  15| TVK=EXP(THETA(2))
#>  16| MU_2=LOG(TVK)
#>  17| K = EXP(MU_2+ETA(2))
#>  18| 
#>  19| TVV=EXP(THETA(3))
#>  20| 
#>  21| TVV = TVVCOV*TVV
#>  22| MU_3=LOG(TVV)
#>  23| V = EXP(MU_3+ETA(3))
#>  24| 
#>  25| CL = K*V
#>  26| 
#>  27| S2 = V
#>  28| 
#> 
#> $`execute.Models/m3`
#>   1| $PK
#>   2| 
#>   3| ;;; TVVWT-DEFINITION START
#>   4| TVVWT= ((WT/70.5)**THETA(4))
#>   5| ;;; TVVWT-DEFINITION END
#>   6| 
#>   7| ;;; TVV-RELATION START
#>   8| TVVCOV=TVVWT
#>   9| ;;; TVV-RELATION END
#>  10| 
#>  11| TVKA=EXP(THETA(1))
#>  12| MU_1=LOG(TVKA)
#>  13| KA = EXP(MU_1+ETA(1))
#>  14| 
#>  15| TVK=EXP(THETA(2))
#>  16| MU_2=LOG(TVK)
#>  17| K = EXP(MU_2+ETA(2))
#>  18| 
#>  19| TVV=EXP(THETA(3))
#>  20| 
#>  21| TVV = TVVCOV*TVV
#>  22| MU_3=LOG(TVV)
#>  23| V = EXP(MU_3+ETA(3))
#>  24| 
#>  25| CL = K*V
#>  26| 
#>  27| S2 = V
#>  28| 
#> 
#> $`execute.Models/m4`
#>   1| $PK
#>   2| 
#>   3| ;;; TVVWT-DEFINITION START
#>   4| TVVWT= ((WT/70.5))
#>   5| ;;; TVVWT-DEFINITION END
#>   6| 
#>   7| ;;; TVV-RELATION START
#>   8| TVVCOV=TVVWT
#>   9| ;;; TVV-RELATION END
#>  10| 
#>  11| TVKA=EXP(THETA(1))
#>  12| MU_1=LOG(TVKA)
#>  13| KA = EXP(MU_1+ETA(1))
#>  14| 
#>  15| TVK=EXP(THETA(2))
#>  16| MU_2=LOG(TVK)
#>  17| K = EXP(MU_2+ETA(2))
#>  18| 
#>  19| TVV=EXP(THETA(3))
#>  20| 
#>  21| TVV = TVVCOV*TVV
#>  22| MU_3=LOG(TVV)
#>  23| V = EXP(MU_3+ETA(3))
#>  24| 
#>  25| CL = K*V
#>  26| 
#>  27| S2 = V
#>  28| 
#> 

unlink(temp_data_file)