Skip to content

Shiny App inside R Package

3 messages · Axel Urbiz, Thierry Onkelinx, Marc Girondot

#
Dear List,

I have a wrapper function that creates a Shiny App, as illustrated below.

I'd like to include the function myApp() inside a package. I'd appreciate
your guidance here, as I could not find good instructions on this online.


myApp <- function(x) {
  require(shiny)
  shinyApp(
    ui = fluidPage(
      sidebarLayout(
        sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)),
        mainPanel(plotOutput("hist"))
      )
    ),
    server = function(input, output) {
      output$hist <- renderPlot(
        hist(x, breaks = input$n,
             col = "skyblue", border = "white")
      )
    }
  )
}

myApp(rnorm(100))

Regards,
Axel.
#
Dear Axel,

I tend to place Shiny apps in the "inst" directory of the package. See
https://stackoverflow.com/questions/37830819/developing-shiny-app-as-a-package-and-deploying-it-to-shiny-server

Best regards,
ir. Thierry Onkelinx
Statisticus/ Statiscian

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
AND FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx at inbo.be
Kliniekstraat 25, B-1070 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data. ~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////


Van 14 tot en met 19 december 2017 verhuizen we uit onze vestiging in
Brussel naar het Herman Teirlinckgebouw op de site Thurn & Taxis.
Vanaf dan ben je welkom op het nieuwe adres: Havenlaan 88 bus 73, 1000 Brussel.

///////////////////////////////////////////////////////////////////////////////////////////



2017-09-17 19:31 GMT+02:00 Axel Urbiz <axel.urbiz at gmail.com>:
#
I have this working in my package embryogrowth available in CRAN.

I have a function to call the shiny app:
web.tsd <- function() {

 ? if (!requireNamespace("shiny", quietly = TRUE)) {
 ??? stop("shiny package is absent; Please install it first")
 ? }

getFromNamespace("runApp", ns="shiny")(appDir = system.file("shiny", 
package="embryogrowth"),
 ?????????????????????????????????????? launch.browser =TRUE)

}

I have a folder inst and inside a folder shiny.
Within this folder inst/shiny/ I copy the two files server.R and ui.R

Marc

Le 17/09/2017 ? 19:31, Axel Urbiz a ?crit?:
.