Learn R Programming

interactiveDisplay (version 1.10.2)

.runApp: Run a shiny app, capturing results to the R session

Description

This utility function launches a shiny visualization application, either in the RStudio viewer pane (if run under RStudio) or in the browser.

Usage

.runApp(app, ...)

Arguments

app
The shiny application definition, see ?shiny::runApp.
...
additional arguments passed to shiny::runApp().

Value

  • The return value of shiny::runApp.

Examples

Run this code
if (interactive()) {
    require(shiny)

    app <- list(
        ui = fluidPage(
          title="Who Am I?",
          sidebarLayout(
              position="left",
              sidebarPanel(
                  h1("Your name"),
                  textInput("your_name", "Your name?", "Anonymous"),
                  actionButton("done", "Done")),
              mainPanel(
                  "Hi", textOutput("your_name", inline=TRUE))
              )),

        server = function(input, output) {
            output$your_name <- renderText(input$your_name)
            observe({
                if (input$done > 0)
                    isolate(stopApp(returnValue = input$your_name))
            })

        })

    .runApp(app)
}

Run the code above in your browser using DataLab