Winston Chang [aut] (ORCID: <https://orcid.org/0000-0002-1576-2126>), Joe Cheng [aut], JJ Allaire [aut], Carson Sievert [aut, cre] (ORCID: <https://orcid.org/0000-0002-4958-2844>), Barret Schloerke [aut] (ORCID: <https://orcid.org/0000-0001-9986-114X>), Garrick Aden-Buie [aut] (ORCID: <https://orcid.org/0000-0002-7111-0077>), Yihui Xie [aut], Jeff Allen [aut], Jonathan McPherson [aut], Alan Dipert [aut], Barbara Borges [aut], Posit Software, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>), jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/www/shared/jqueryui/AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Prem Nawaz Khan [ctb] (Bootstrap accessibility plugin), Victor Tsaran [ctb] (Bootstrap accessibility plugin), Dennis Lembree [ctb] (Bootstrap accessibility plugin), Srinivasu Chakravarthula [ctb] (Bootstrap accessibility plugin), Cathy O'Connor [ctb] (Bootstrap accessibility plugin), PayPal, Inc [cph] (Bootstrap accessibility plugin), Stefan Petre [ctb, cph] (Bootstrap-datepicker library), Andrew Rowls [ctb, cph] (Bootstrap-datepicker library), Brian Reavis [ctb, cph] (selectize.js library), Salmen Bejaoui [ctb, cph] (selectize-plugin-a11y library), Denis Ineshin [ctb, cph] (ion.rangeSlider library), Sami Samhuri [ctb, cph] (Javascript strftime library), SpryMedia Limited [ctb, cph] (DataTables library), Ivan Sagalaev [ctb, cph] (highlight.js library), R Core Team [ctb, cph] (tar implementation from R) · rdrr.io
shinyApp: Create a Shiny app object
View source: R/shinyapp.R
Description
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).
Usage
shinyApp(
ui,
server,
onStart = NULL,
options = list(),
uiPattern = "/",
enableBookmarking = NULL
)
shinyAppDir(appDir, options = list())
shinyAppFile(appFile, options = list())
Arguments
ui |
The UI definition of the app (for example, a call to
fluidPage() with nested controls).
If bookmarking is enabled (see enableBookmarking), this must be
a single argument function that returns the UI definition.
|
server |
A function with three parameters: input, output, and
session. The function is called once for each session ensuring that each
app is independent.
|
onStart |
A function that will be called before the app is actually run.
This is only needed for shinyAppObj, since in the shinyAppDir
case, a global.R file can be used for this purpose.
|
options |
Named options that should be passed to the runApp call
(these can be any of the following: "port", "launch.browser", "host", "quiet",
"display.mode" and "test.mode"). You can also specify width and
height parameters which provide a hint to the embedding environment
about the ideal height/width for the app.
|
uiPattern |
A regular expression that will be applied to each GET
request to determine whether the ui should be used to handle the
request. Note that the entire request path must match the regular
expression in order for the match to be considered successful.
|
enableBookmarking |
Can be one of "url", "server", or
"disable". The default value, NULL, will respect the setting from
any previous calls to enableBookmarking(). See enableBookmarking()
for more information on bookmarking your app.
|
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
|
Details
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().
Value
An object that represents the app. Printing the object or passing it
to runApp() will run the app.
Examples
## 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)
}
shiny documentation built on June 21, 2026, 5:07 p.m.
Read the original on rdrr.io ↗