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 / no-spaces.R
Last active February 15, 2016 20:00
Run a model in project directory with no spaces
library(mrgsolve)
## Create a project directory with no spaces in the path
proj <- "c:/my_mrgsolve_models"
if(!file.exists(proj)) dir.create(proj)
code <- '
$PARAM KE = 0.1
$CMT CENT
$ODE dxdt_CENT = -KE*CENT;
@kylebaron
kylebaron / shiny_mc.R
Last active February 26, 2016 05:32
Problems with RNG when using mclapply inside shiny app
library(shiny)
library(mrgsolve)
library(dplyr)
library(magrittr)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
set.seed(101)
mc.reset.stream()
@kylebaron
kylebaron / shiny_mv_mc.R
Last active February 26, 2016 05:31
Shiny + mclapply + mvrnorm
library(MASS)
library(shiny)
library(mrgsolve)
library(dplyr)
library(magrittr)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
@kylebaron
kylebaron / shiny_mc_Rcpp.R
Last active February 26, 2016 15:07
Shiny + mclapply + stochastic simulation in Rcpp (no mrgsolve involvement)
library(shiny)
library(dplyr)
library(parallel)
library(Rcpp)
RNGkind("L'Ecuyer-CMRG")
set.seed(101)
mc.reset.stream()
@kylebaron
kylebaron / shiny_SEED.R
Last active March 4, 2016 18:22
Manually pass the seed
library(shiny)
library(mrgsolve)
library(dplyr)
library(magrittr)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
set.seed(101)
mc.reset.stream()
@kylebaron
kylebaron / shinySETRNG.R
Last active March 4, 2016 19:17
Set RNGkind in worker
library(shiny)
library(mrgsolve)
library(dplyr)
library(magrittr)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
set.seed(101)
mc.reset.stream()
@kylebaron
kylebaron / path.R
Created March 15, 2016 18:07
Check or set PATH
# Check your current path
path0 <- Sys.getenv("PATH")
path0
# You need to check the specifics of where Rtools is located on your system
path <- "C:\\Program Files\\R\\R-3.2.3\\bin\\x64;c:\\Rtools32\\bin;c:\\Rtools32\\gcc-4.6.3\\bin;"
# Create a new path
path <- paste0(path,path0,sep=";")
@kylebaron
kylebaron / user.md
Last active April 15, 2016 15:27
User-defined function

A user-defined function

This uses just C++ for now.

user <- '
#include <vector>
#include <numeric>
library(dplyr)
library(magrittr)
library(mrgsolve)
library(rbenchmark)
code <- '
$CMT GUT CENT PERIPH
$PKMODEL ncmt=2, trans=2
$PARAM CL=1, V2=20, Q = 12, V3 = 200, KA=2
@kylebaron
kylebaron / omega_cor_name.md
Last active April 27, 2016 01:52
$OMEGA with name and cor
library(dplyr)
library(magrittr)
library(mrgsolve)
code <- '
$CMT GUT  
$PKMODEL ncmt=1,depot=FALSE