Skip to content

Instantly share code, notes, and snippets.

View kylebaron's full-sized avatar
🏠
Working from home

Kyle Baron kylebaron

🏠
Working from home
View GitHub Profile
@kylebaron
kylebaron / shinymod.md
Last active April 28, 2016 04:30
Pre-compile mrgsolve model when using Shiny App
library(mrgsolve)

## mrgsolve: Community Edition

## www.github.com/metrumresearchgroup

Setup the model

code <- '

@kylebaron
kylebaron / R_NOT_FOUND.R
Created April 29, 2016 13:56
R not found
Sys.setenv(PATH="")
library(mrgsolve)
## Warning:
## Could not find R program in PATH.
## If you are compiling your own models, please first make sure that
## the following command runs properly from your R prompt:
## system("R CMD SHLIB -v")
@kylebaron
kylebaron / dollar_theta.md
Created May 12, 2016 18:07
THETAs from multiple models
library(mrgsolve)

## mrgsolve: Community Edition

## www.github.com/metrumresearchgroup/mrgsolve

code <- '
$THETA 
1 2 3

$THETA name="theta"

@kylebaron
kylebaron / wt.R
Created June 22, 2016 16:03
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
if(!require(devtools)) install.packages("devtools")
.libPaths("~/Rlibs") ## Change this to your Rlibs directory
if(!require(devtools)) install.packages("devtools")
library(devtools)
update.packages(ask=FALSE)
devtools::install_github("metrumresearchgroup/[email protected]", subdir="rdev", type="source")
@kylebaron
kylebaron / simargs.R
Created August 11, 2016 16:39
simargs
>
> data <- expand.ev(amt=100)
>
>
> mod <- mrgsolve:::house()
> x <- mod %>% data_set(data)
> simargs(x)
$data
ID amt evid cmt time ..zeros..
[1,] 1 100 1 1 0 0
library(future)
library(future.BatchJobs)
library(mrgsolve)
library(dplyr)
library(parallel)
mod <- mrgsolve:::house()
data <- expand.ev(amt=100,ID=1:200)
@kylebaron
kylebaron / future.R
Last active August 15, 2016 19:46
future
> f <- future({
+ a <- 7
+ b <- 3
+ c <- 2
+ a * b * c
+ })
> as.list(f)
$local
[1] TRUE
@kylebaron
kylebaron / render_template_Rmd
Last active October 6, 2016 03:15
Render template
---
output: pdf_document
params:
model: ""
project: ""
---
```{r,echo=FALSE}