appshot | R Documentation |
appshot
performs a webshot
using two different methods
depending upon the object provided. If a 'character' is provided (pointing to
an app.R file or app directory) an isolated background R process is launched
to run the Shiny application. The current R process then captures the
webshot
. When a Shiny application object is supplied to
appshot
, it is reversed: the Shiny application runs in the current R
process and an isolated background R process is launched to capture a
webshot
. The reason it is reversed in the second case has to do
with scoping: although it would be preferable to run the Shiny application in
a background process and call webshot
from the current process, with
Shiny application objects, there are potential scoping errors when run this
way.
appshot(
app,
file = "webshot.png",
...,
port = getOption("shiny.port"),
envvars = NULL
)
## S3 method for class 'character'
appshot(
app,
file = "webshot.png",
...,
port = getOption("shiny.port"),
envvars = NULL
)
## S3 method for class 'shiny.appobj'
appshot(
app,
file = "webshot.png",
...,
port = getOption("shiny.port"),
envvars = NULL,
webshot_timeout = 60
)
app |
A Shiny app object, or a string naming an app directory. |
file |
A vector of names of output files. Should end with an image file
type ( |
... |
Other arguments to pass on to |
port |
Port that Shiny will listen on. |
envvars |
A named character vector or named list of environment variables and values to set for the Shiny app's R process. These will be unset after the process exits. This can be used to pass configuration information to a Shiny app. |
webshot_timeout |
The maximum number of seconds the phantom application
is allowed to run before killing the process. If a delay argument is
supplied (in |
Invisibly returns the normalized path to all screenshots taken. The character vector will have a class of '"webshot"'.
if (interactive()) {
appdir <- system.file("examples", "01_hello", package="shiny")
# With a Shiny directory
appshot(appdir, "01_hello.png")
# With a Shiny App object
shinyapp <- shiny::shinyAppDir(appdir)
appshot(shinyapp, "01_hello_app.png")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.