runApp(appDir = getwd(), port = getOption("shiny.port"),
launch.browser = getOption("shiny.launch.browser", interactive()),
host = getOption("shiny.host", "127.0.0.1"), workerId = "",
quiet = FALSE, display.mode = c("auto", "normal", "showcase"),
test.mode = getOption("shiny.testmode", FALSE))
server.R
, plus, either ui.R
or
a www
directory that contains the file index.html
.
app.R
.
.R
file containing a Shiny application, ending with an
expression that produces a Shiny app object.
ui
and server
components.
shinyApp
.
port
is not specified, and the shiny.port
option is set (with
options(shiny.port = XX)
), then that port will be used. Otherwise,
use a random port.shiny.host
option, if set, or "127.0.0.1"
if not. See
Details."showcase"
, shows application code and metadata from a
DESCRIPTION
file in the application directory alongside the
application. If set to "normal"
, displays the application normally.
Defaults to "auto"
, which displays the application in the mode given
in its DESCRIPTION
file, if any.shiny.testmode
option, or FALSE if the option is not set."127.0.0.1"
means that, contrary to previous versions of Shiny, only
the current machine can access locally hosted Shiny apps. To allow other
clients to connect, use the value "0.0.0.0"
instead (which was the
value that was hard-coded into Shiny in 0.8.0 and earlier).## Not run: ------------------------------------
# # Start app in the current working directory
# runApp()
#
# # Start app in a subdirectory called myapp
# runApp("myapp")
## ---------------------------------------------
## Only run this example in interactive R sessions
if (interactive()) {
options(device.ask.default = FALSE)
# Apps can be run without a server.r and ui.r file
runApp(list(
ui = bootstrapPage(
numericInput('n', 'Number of obs', 100),
plotOutput('plot')
),
server = function(input, output) {
output$plot <- renderPlot({ hist(runif(input$n)) })
}
))
# Running a Shiny app object
app <- shinyApp(
ui = bootstrapPage(
numericInput('n', 'Number of obs', 100),
plotOutput('plot')
),
server = function(input, output) {
output$plot <- renderPlot({ hist(runif(input$n)) })
}
)
runApp(app)
}
Run the code above in your browser using DataLab