| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/shinyapp.R |
| 3 |
\name{shinyApp} |
| 4 |
\alias{shinyApp} |
| 5 |
\alias{shinyAppDir} |
| 6 |
\alias{shinyAppFile} |
| 7 |
\title{Create a Shiny app object} |
| 8 |
\usage{ |
| 9 |
shinyApp( |
| 10 |
ui, |
| 11 |
server, |
| 12 |
onStart = NULL, |
| 13 |
options = list(), |
| 14 |
uiPattern = "/", |
| 15 |
enableBookmarking = NULL |
| 16 |
) |
| 17 |
|
| 18 |
shinyAppDir(appDir, options = list()) |
| 19 |
|
| 20 |
shinyAppFile(appFile, options = list()) |
| 21 |
} |
| 22 |
\arguments{ |
| 23 |
\item{ui}{The UI definition of the app (for example, a call to |
| 24 |
\code{fluidPage()} with nested controls). |
| 25 |
|
| 26 |
If bookmarking is enabled (see \code{enableBookmarking}), this must be |
| 27 |
a single argument function that returns the UI definition.} |
| 28 |
|
| 29 |
\item{server}{A function with three parameters: \code{input}, \code{output}, and |
| 30 |
\code{session}. The function is called once for each session ensuring that each |
| 31 |
app is independent.} |
| 32 |
|
| 33 |
\item{onStart}{A function that will be called before the app is actually run. |
| 34 |
This is only needed for \code{shinyAppObj}, since in the \code{shinyAppDir} |
| 35 |
case, a \code{global.R} file can be used for this purpose.} |
| 36 |
|
| 37 |
\item{options}{Named options that should be passed to the \code{runApp} call |
| 38 |
(these can be any of the following: "port", "launch.browser", "host", "quiet", |
| 39 |
"display.mode" and "test.mode"). You can also specify \code{width} and |
| 40 |
\code{height} parameters which provide a hint to the embedding environment |
| 41 |
about the ideal height/width for the app.} |
| 42 |
|
| 43 |
\item{uiPattern}{A regular expression that will be applied to each \code{GET} |
| 44 |
request to determine whether the \code{ui} should be used to handle the |
| 45 |
request. Note that the entire request path must match the regular |
| 46 |
expression in order for the match to be considered successful.} |
| 47 |
|
| 48 |
\item{enableBookmarking}{Can be one of \code{"url"}, \code{"server"}, or |
| 49 |
\code{"disable"}. The default value, \code{NULL}, will respect the setting from |
| 50 |
any previous calls to \code{\link[=enableBookmarking]{enableBookmarking()}}. See \code{\link[=enableBookmarking]{enableBookmarking()}} |
| 51 |
for more information on bookmarking your app.} |
| 52 |
|
| 53 |
\item{appDir}{Path to directory that contains a Shiny app (i.e. a server.R |
| 54 |
file and either ui.R or www/index.html)} |
| 55 |
|
| 56 |
\item{appFile}{Path to a .R file containing a Shiny application} |
| 57 |
} |
| 58 |
\value{ |
| 59 |
An object that represents the app. Printing the object or passing it |
| 60 |
to \code{\link[=runApp]{runApp()}} will run the app. |
| 61 |
} |
| 62 |
\description{ |
| 63 |
These functions create Shiny app objects from either an explicit UI/server |
| 64 |
pair (\code{shinyApp}), or by passing the path of a directory that contains a |
| 65 |
Shiny app (\code{shinyAppDir}). |
| 66 |
} |
| 67 |
\details{ |
| 68 |
Normally when this function is used at the R console, the Shiny app object is |
| 69 |
automatically passed to the \code{print()} function, which runs the app. If |
| 70 |
this is called in the middle of a function, the value will not be passed to |
| 71 |
\code{print()} and the app will not be run. To make the app run, pass the app |
| 72 |
object to \code{print()} or \code{\link[=runApp]{runApp()}}. |
| 73 |
} |
| 74 |
\examples{ |
| 75 |
## Only run this example in interactive R sessions |
| 76 |
if (interactive()) { |
| 77 |
options(device.ask.default = FALSE) |
| 78 |
|
| 79 |
shinyApp( |
| 80 |
ui = fluidPage( |
| 81 |
numericInput("n", "n", 1), |
| 82 |
plotOutput("plot") |
| 83 |
), |
| 84 |
server = function(input, output) { |
| 85 |
output$plot <- renderPlot( plot(head(cars, input$n)) ) |
| 86 |
} |
| 87 |
) |
| 88 |
|
| 89 |
shinyAppDir(system.file("examples/01_hello", package="shiny")) |
| 90 |
|
| 91 |
|
| 92 |
# The object can be passed to runApp() |
| 93 |
app <- shinyApp( |
| 94 |
ui = fluidPage( |
| 95 |
numericInput("n", "n", 1), |
| 96 |
plotOutput("plot") |
| 97 |
), |
| 98 |
server = function(input, output) { |
| 99 |
output$plot <- renderPlot( plot(head(cars, input$n)) ) |
| 100 |
} |
| 101 |
) |
| 102 |
|
| 103 |
runApp(app) |
| 104 |
} |
| 105 |
} |