Skip to content

Instantly share code, notes, and snippets.

@kylebaron
Created June 22, 2016 16:03
Show Gist options
  • Save kylebaron/f17ca15332fe6f908cf6057795e120e1 to your computer and use it in GitHub Desktop.
Save kylebaron/f17ca15332fe6f908cf6057795e120e1 to your computer and use it in GitHub Desktop.
WT from function or from parameter
library(mrgsolve)
code <- '
$GLOBAL
double wt_fr_age(const double age) {
return(age*2/3);
}
$PARAM WEIGHT = 5, AGE=2, WTFLAG = 0
$MAIN
double WT = WTFLAG==1 ? wt_fr_age(AGE) : WEIGHT;
$CAPTURE WT
'
mod <- mcode("wt",code,warn=FALSE)
mod %>% mrgsim
mod %>% param(WTFLAG=1) %>% mrgsim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment