Description Usage Arguments Details Value Examples
These functions create Shiny app objects from either an explicit UI/server
pair (shinyApp), or by passing the path of a directory that contains a
Shiny app (shinyAppDir).
| 1 2 3 4 5 6 7 8 9 10 11 12 | shinyApp(
  ui,
  server,
  onStart = NULL,
  options = list(),
  uiPattern = "/",
  enableBookmarking = NULL
)
shinyAppDir(appDir, options = list())
shinyAppFile(appFile, options = list())
 | 
| ui | The UI definition of the app (for example, a call to
 If bookmarking is enabled (see  | 
| server | A function with three parameters:  | 
| onStart | A function that will be called before the app is actually run.
This is only needed for  | 
| options | Named options that should be passed to the  | 
| uiPattern | A regular expression that will be applied to each  | 
| enableBookmarking | Can be one of  | 
| appDir | Path to directory that contains a Shiny app (i.e. a server.R file and either ui.R or www/index.html) | 
| appFile | Path to a .R file containing a Shiny application | 
Normally when this function is used at the R console, the Shiny app object is
automatically passed to the print() function, which runs the app. If
this is called in the middle of a function, the value will not be passed to
print() and the app will not be run. To make the app run, pass the app
object to print() or runApp().
An object that represents the app. Printing the object or passing it
to runApp() will run the app.
| 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 | ## Only run this example in interactive R sessions
if (interactive()) {
  options(device.ask.default = FALSE)
  shinyApp(
    ui = fluidPage(
      numericInput("n", "n", 1),
      plotOutput("plot")
    ),
    server = function(input, output) {
      output$plot <- renderPlot( plot(head(cars, input$n)) )
    }
  )
  shinyAppDir(system.file("examples/01_hello", package="shiny"))
  # The object can be passed to runApp()
  app <- shinyApp(
    ui = fluidPage(
      numericInput("n", "n", 1),
      plotOutput("plot")
    ),
    server = function(input, output) {
      output$plot <- renderPlot( plot(head(cars, input$n)) )
    }
  )
  runApp(app)
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.