shinymlx: Automatic code generation for Shiny applications

Description Usage Arguments Details Value Examples

View source: R/shinymlx.R

Description

Creates a Shiny application for longitudinal data model

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
shinymlx(
  model,
  parameter = NULL,
  output = NULL,
  treatment = NULL,
  regressor = NULL,
  group = NULL,
  data = NULL,
  appname = "shinymlxApp",
  style = "basic",
  settings = NULL,
  title = " "
)

Arguments

model

a Mlxtran model used for the simulation

parameter

a vector, or a list of shiny widgets

output

a list - or a list of lists - with fields:

  • name: a vector of output names

  • time: a vector of times, or a vector (min, max, step)

treatment

a list with fields

  • tfd : first time of dose,

  • amount : amount,

  • nd : number of doses,

  • ii : interdose interval,

  • type : the type of input,

Input argument of Simulx can also be used, i.e. a list with fields time, amount, rate, tinf, type, target.

regressor

a list, or a list of lists, with fields

  • name : a vector of regressor names,

  • time : a vector of times,

  • value : a vector of values.

group

a list, or a list of lists, with fields:

  • size : size of the group (default=1),

  • level : level(s) of randomization,

  • parameter : if different parameters per group are defined,

  • output : if different outputs per group are defined,

  • treatment : if different treatements per group are defined,

  • regressor : if different regression variables per group are defined.

data

data to display with the plot (either a data frame or the name of a file)

appname

the name of the application (and possibly its path)

style

the style of the Shiny app

  • "basic": basic Shiny app with a single side bar (default)

  • "navbar1": navigation bar and tabPanels (including outputs)

  • "navbar2": navigation bar and tabPanels (outputs separated)

  • "dashboard1" : Shiny dashboard,

settings

a list of settings

  • "tabstyle" : look of the tabs c("tabs","pills"),

  • "select.x" : display the list of variables available for the x-axis c(TRUE,FALSE),

  • "select.y" : display the list of variables available for the y-axis c(TRUE,FALSE),

  • "select.log" : log scale option c(TRUE,FALSE),

  • "select.ref" : reference curves option c(TRUE,FALSE)

title

the title of the application

Details

shinymlx automatically generates files ui.R and server.R required for a Shiny application.

Elements of parameters and treatment can be either scalars or lists. A scalar automatically generates a slider with default minimum and maximum values and default step. A list may contain the type of widget ("slider", "select", "numeric") and the settings defining the widget: (value, min, max, step) for slider, (selected, choices) for select and value for numeric.

See http://simulx.webpopix.org/mlxr/shinymlx/ for more details.

Value

A Shiny app with files ui.R, server.R and model.txt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
library(mlxR)
PKPDmodel <- inlineModel("
[LONGITUDINAL] 
input={ka,V,Cl,Imax,IC50,S0,kout}
EQUATION:
C     = pkmodel(ka, V, Cl)
E_0   = S0 
ddt_E = kout*((1-Imax*C/(C+IC50))*S0- E)  
")

p1  <- c(ka=0.5, V=10, Cl=1)
p2  <- c(Imax=0.5, IC50=0.03, S0=100, kout=0.1)
adm <- list(tfd=5, nd=15, ii=12, amount=1)
f1  <- list(name = 'C', time = seq(0, 250, by=1))
f2  <- list(name = 'E', time = seq(0, 250, by=1))
f   <- list(f1, f2)

shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f,
         style="dashboard1")

#------------------------------------------------------------------------
p1 <- list(
  ka    = list(widget="slider", value=0.5, min=0.1, max=2,  step=0.1),
  V     = list(widget="slider", value=10,  min=2,   max=20, step=2),
  Cl    = list(widget="slider", value=1,   min=0.1, max=2,  step=0.1)
)  
adm <- list(
  tfd    = list(widget="slider", value=5,  min=0, max=100, step=5),
  nd     = list(widget="numeric", value=15),
  ii     = list(widget="select", selected=12, choices=c(3,6,12,18,24)),
  amount = list(widget="slider", value=40, min=0, max=50, step=5)
)
s <- list(select.x=FALSE, select.y=FALSE)
shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f, 
         style="navbar1", settings=s)

## End(Not run)

Example output

Loading required package: ggplot2
Warning message:
no DISPLAY variable so Tk is not available 
[1] "shinymlxApp"
[1] "shinymlxApp"

mlxR documentation built on Jan. 19, 2021, 5:06 p.m.