The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Shiny apps

Introduction

Shiny apps are a great way of visualizing a (translated) model. The main advantage of a shiny app for a simulation model is that you can easily test the effect of different parameters on the outcome of a simulation. When translating a model using the amp.sim package, there is a standardized way models are created. This makes it possible to automatically create a shiny app for such a model.

Basics

To create a shiny app for a model, you will need a translated model and a single function call:

library(amp.sim)
mod2shiny(parvector = c(THETA1=0.1,THETA2=0.3),
          modfile   = 'model.cpp',
          evnt      = ev(amt = 100, ii = 24, addl = 1),
          naming    = c(THETA1 = "KA (1/h)", THETA2 = "CL (l/h)"),
          framework = "mrgsolve"
          outloc    = "simApp")

The most important parameters for the function are:

Once the function is called, the appropriate app files are created (e.g. ui.r/server.r and directories to store app files). Instructions are shown on the screen how you can directly run the shiny app, which is basically just a call to shiny::runApp.

App appearance

When the app is created an app will be created that will look something like:

Figure 1: example screenshot

The app is basic but already has some features build into it:

Manual adaptations

Once the app is created you can directly use it for simple type of simulations. However in many cases you would want to make manual adaptations the app. Because the mod2shiny function creates the applicable app files, it is very easy to make manual adaptations to these files. In the chunk below we can see how we can implement different dose heights by adjusting only two lines of code:

# part added in ui.r
numericInput(inputId = 'DOSE', label='Dose (mg):', value=100)
# part added in server.r
events <- ev(amt = input$DOSE, ii = 24, addl = 1)

To add information regarding the app, you can adapt the ui.r file and adapt the part that reads “Placeholder for …”. Finally, you can add your own logo to the app either by providing this as an argument to mod2shiny or by replacing the file in the www directory (using the same name). This can also be done for the model scheme, just replace the file in this directory with a same named file. In case you want to create a more complex app, this method can be used to create an initial starting point.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.