Debian Codegraph @

man/run.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/shiny.R
3 \name{run}
4 \alias{run}
5 \title{Run a Shiny document}
6 \usage{
7 run(
8 file = "index.Rmd",
9 dir = dirname(file),
10 default_file = NULL,
11 auto_reload = TRUE,
12 shiny_args = NULL,
13 render_args = NULL
14 )
15 }
16 \arguments{
17 \item{file}{Path to the R Markdown document to launch in a web browser.
18 Defaults to \code{index.Rmd} in the current working directory, but may be
19 \code{NULL} to skip launching a browser.}
20
21 \item{dir}{The directory from which to to read input documents. Defaults to
22 the parent directory of \code{file}.}
23
24 \item{default_file}{The file to serve at the Shiny server's root URL. If
25 \code{NULL} (the default), a sensible default is chosen (see Details)}
26
27 \item{auto_reload}{If \code{TRUE} (the default), automatically reload the
28 Shiny application when the file currently being viewed is changed on disk.}
29
30 \item{shiny_args}{Additional arguments to \code{\link[shiny:runApp]{runApp}}.}
31
32 \item{render_args}{Additional arguments to \code{\link{render}}.}
33 }
34 \value{
35 Invisible NULL.
36 }
37 \description{
38 Start a Shiny server for the given document, and render it for display.
39 }
40 \details{
41 The \code{run} function runs a Shiny document by starting a Shiny
42 server associated with the document. The \code{shiny_args} parameter can be
43 used to configure the server; see the \code{\link[shiny:runApp]{runApp}}
44 documentation for details.
45
46 Once the server is started, the document will be rendered using
47 \code{\link{render}}. The server will initiate a render of the document
48 whenever necessary, so it is not necessary to call \code{run} every time
49 the document changes: if \code{auto_reload} is \code{TRUE}, saving the
50 document will trigger a render. You can also manually trigger a render by
51 reloading the document in a Web browser.
52
53 The server will render any R Markdown (\code{.Rmd}) document in \code{dir};
54 the \code{file} argument specifies only the initial document to be
55 rendered and viewed. You can therefore link to other documents in the
56 directory using standard Markdown syntax, e.g.
57 \code{[Analysis Page 2](page2.Rmd)}.
58
59 If \code{default_file} is not specified, nor is a file specified on the
60 URL, then the default document to serve at \code{/} is chosen from (in
61 order of preference):
62 \itemize{
63 \item{If \code{dir} contains only one \code{Rmd}, that \code{Rmd}.}
64 \item{The file \file{index.Rmd}, if it exists in \code{dir}.}
65 \item{The first \code{Rmd} that has \code{runtime: shiny} in its YAML metadata.}
66 \item{The file \file{index.html} (or \file{index.htm}), if it exists in \code{dir}.}
67 }
68
69 If you wish to share R code between your documents, place it in a file
70 named \code{global.R} in \code{dir}; it will be sourced into the global
71 environment.
72 }
73 \note{
74 Unlike \code{\link{render}}, \code{run} does not render the document to
75 a file on disk. In most cases a Web browser will be started automatically
76 to view the document; see \code{launch.browser} in the
77 \code{\link[shiny:runApp]{runApp}} documentation for details.
78
79 When using an external web browser with the server, specify the name of the
80 R Markdown file to view in the URL (e.g.
81 \code{http://127.0.0.1:1234/foo.Rmd}). A URL without a filename will show
82 the \code{default_file} as described above.
83 }
84 \examples{
85 \dontrun{
86 # Run the Shiny document "index.Rmd" in the current directory
87 rmarkdown::run()
88
89 # Run the Shiny document "shiny_doc.Rmd" on port 8241
90 rmarkdown::run("shiny_doc.Rmd", shiny_args = list(port = 8241))
91 }
92 }