% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mod2shiny.r
\name{mod2shiny}
\alias{mod2shiny}
\title{Creates a basic simulation app for a given R model}
\usage{
mod2shiny(
  parvector,
  modfile,
  evnt,
  init = NULL,
  naming = NULL,
  apptitle = "Shiny app title",
  outloc = ".",
  omega = NULL,
  sigma = NULL,
  delloc = FALSE,
  framework = "deSolve",
  logo = paste0(system.file(package = "amp.sim"), "/logo.png"),
  times = NULL
)
}
\arguments{
\item{parvector}{named vector with the model parameters, should contain all parameters used by the model}

\item{modfile}{A script with the model defined in it, it is assumed that this file is created using \code{\link[amp.sim]{convert_nonmem}}}

\item{evnt}{dataframe with the events used by the model (this is saved as rds together with the app)}

\item{init}{vector with the compartment initialization (only applicable for deSolve framework)}

\item{naming}{named vector with the names in parvector and the new values to use within the shiny app}

\item{apptitle}{string with the title to be used for the app}

\item{outloc}{character with location where the resulting shiny app should be saved}

\item{omega}{vector with the omega matrix for the model (only applicable for rxode2 framework)}

\item{sigma}{vector with the sigma matrix for the model (only applicable for rxode2 framework)}

\item{delloc}{logical indicating if the location should be deleted first}

\item{framework}{character indicating the simulation framework that was used, currently "deSolve", "rxode2", "nonmem2rx" and "mrgsolve" are supported}

\item{logo}{character with a png of the company logo added in the header of the shiny app}

\item{times}{character vector with the times to simulate or set to NULL to use a default time vector}
}
\value{
creates necessary app files for a shiny simulation app
}
\description{
This function fills in a default template for simulations within shiny
}
\details{
This function creates a default shiny app that can be used as a starting point for further
development. There are already some basic features available but it is intended to be adapted when used
for production. For the automatic creation of an app it is assumed that the model is created using the \link{convert_nonmem}
function. Although it is not strictly necessary, the information provided to this function will be in the correct format
when this function is used. Some of the arguments in this function are only necessary in case a certain conversion framework
is used. In general a single subject is simulated, but be aware that for the deSolve and rxode2 framework OMEGA/ETA is implemented.
}
\examples{

nmmod <- system.file("example_models","PK.1CMT.ORAL.mod", package = "amp.sim")
outf  <- tempfile()
convert_nonmem(nmmod, out=outf, verbose = FALSE)
prm   <- c(THETA1 = 0.3, THETA2 = 2, THETA3 = 5)
evnt  <- mrgsolve::ev(amt = 100, ii = 24, addl = 1)
nams  <- c(THETA1 = "KA (1/h)", THETA2 = "CL (l/h)", THETA3 = "V (l)") 
mod2shiny(prm, modfile= paste0(outf,".cpp"), evnt = evnt,
          naming = nams, framework = "mrgsolve", outloc=tempdir())

}
\author{
Richard Hooijmaijers
}
