[R] Add wrapper to Shiny in R package

Axel Urbiz axel.urbiz at gmail.com
Thu Sep 21 15:02:46 CEST 2017

Dear List,

I'm trying to add a function that calls a Shiny App in my R package. The
issue is that within my function, I'm creating objects that I'd like to
pass to the app. For instance, from the example below, I'm getting
"Error: object
'xs' not found". How can I pass "xs" explicitly to shinyApp()?

*Under R directory:*

myApp <- function(x, ...) {

  xs <- scale(x)

  shiny::runApp(appDir = system.file("application", package =
"my_package"), ...)


*Under inst/application directory a file named app.R with the following

  ui = fluidPage(
      sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)),
  server = function(input, output) {
    output$hist <- renderPlot(
      hist(xs, breaks = input$n,
           col = "skyblue", border = "white")

Thank you,

	[[alternative HTML version deleted]]

More information about the R-help mailing list