mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
295 lines
17 KiB
HTML
295 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Get or set Shiny options — getShinyOption • shiny</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"><script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"><script src="../pkgdown.js"></script><meta property="og:title" content="Get or set Shiny options — getShinyOption"><meta property="og:description" content='There are two mechanisms for working with options for Shiny. One is the
|
|
options() function, which is part of base R, and the other is the
|
|
shinyOptions() function, which is in the Shiny package. The reason for
|
|
these two mechanisms is has to do with legacy code and scoping.
|
|
The options() function sets options globally, for the duration of the R
|
|
process. The getOption() function retrieves the value of an option. All
|
|
shiny related options of this type are prefixed with "shiny.".
|
|
The shinyOptions() function sets the value of a shiny option, but unlike
|
|
options(), it is not always global in scope; the options may be scoped
|
|
globally, to an application, or to a user session in an application,
|
|
depending on the context. The getShinyOption() function retrieves a value
|
|
of a shiny option. Currently, the options set via shinyOptions are for
|
|
internal use only.'><meta property="og:image" content="/logo.png"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
|
<![endif]--></head><body data-spy="scroll" data-target="#toc">
|
|
|
|
|
|
<div class="container template-reference-topic">
|
|
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<span class="navbar-brand">
|
|
<a class="navbar-link" href="../index.html">shiny</a>
|
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">1.7.4.1</span>
|
|
</span>
|
|
</div>
|
|
|
|
<div id="navbar" class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav"><li>
|
|
<a href="../reference/index.html">Reference</a>
|
|
</li>
|
|
<li>
|
|
<a href="../news/index.html">Changelog</a>
|
|
</li>
|
|
</ul><ul class="nav navbar-nav navbar-right"><li>
|
|
<a href="https://github.com/rstudio/shiny/" class="external-link">
|
|
<span class="fab fa-github fa-lg"></span>
|
|
|
|
</a>
|
|
</li>
|
|
</ul></div><!--/.nav-collapse -->
|
|
</div><!--/.container -->
|
|
</div><!--/.navbar -->
|
|
|
|
|
|
|
|
</header><div class="row">
|
|
<div class="col-md-9 contents">
|
|
<div class="page-header">
|
|
<h1>Get or set Shiny options</h1>
|
|
<small class="dont-index">Source: <a href="https://github.com/rstudio/shiny/blob/HEAD/R/shiny-options.R" class="external-link"><code>R/shiny-options.R</code></a></small>
|
|
<div class="hidden name"><code>shinyOptions.Rd</code></div>
|
|
</div>
|
|
|
|
<div class="ref-description">
|
|
<p>There are two mechanisms for working with options for Shiny. One is the
|
|
<code><a href="https://rdrr.io/r/base/options.html" class="external-link">options()</a></code> function, which is part of base R, and the other is the
|
|
<code>shinyOptions()</code> function, which is in the Shiny package. The reason for
|
|
these two mechanisms is has to do with legacy code and scoping.</p>
|
|
<p>The <code><a href="https://rdrr.io/r/base/options.html" class="external-link">options()</a></code> function sets options globally, for the duration of the R
|
|
process. The <code><a href="https://rdrr.io/r/base/options.html" class="external-link">getOption()</a></code> function retrieves the value of an option. All
|
|
shiny related options of this type are prefixed with <code>"shiny."</code>.</p>
|
|
<p>The <code>shinyOptions()</code> function sets the value of a shiny option, but unlike
|
|
<code><a href="https://rdrr.io/r/base/options.html" class="external-link">options()</a></code>, it is not always global in scope; the options may be scoped
|
|
globally, to an application, or to a user session in an application,
|
|
depending on the context. The <code>getShinyOption()</code> function retrieves a value
|
|
of a shiny option. Currently, the options set via <code>shinyOptions</code> are for
|
|
internal use only.</p>
|
|
</div>
|
|
|
|
<div id="ref-usage">
|
|
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">getShinyOption</span><span class="op">(</span><span class="va">name</span>, default <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span>
|
|
<span></span>
|
|
<span><span class="fu">shinyOptions</span><span class="op">(</span><span class="va">...</span><span class="op">)</span></span></code></pre></div>
|
|
</div>
|
|
|
|
<div id="arguments">
|
|
<h2>Arguments</h2>
|
|
<dl><dt>name</dt>
|
|
<dd><p>Name of an option to get.</p></dd>
|
|
|
|
|
|
<dt>default</dt>
|
|
<dd><p>Value to be returned if the option is not currently set.</p></dd>
|
|
|
|
|
|
<dt>...</dt>
|
|
<dd><p>Options to set, with the form <code>name = value</code>.</p></dd>
|
|
|
|
</dl></div>
|
|
<div id="options-with-options-">
|
|
<h2>Options with <code><a href="https://rdrr.io/r/base/options.html" class="external-link">options()</a></code></h2>
|
|
|
|
|
|
|
|
<dl><dt>shiny.autoreload (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code> when a Shiny app is launched, the
|
|
app directory will be continually monitored for changes to files that
|
|
have the extensions: r, htm, html, js, css, png, jpg, jpeg, gif. If any
|
|
changes are detected, all connected Shiny sessions are reloaded. This
|
|
allows for fast feedback loops when tweaking Shiny UI.</p>
|
|
<p>Since monitoring for changes is expensive (we simply poll for last
|
|
modified times), this feature is intended only for development.</p>
|
|
<p>You can customize the file patterns Shiny will monitor by setting the
|
|
shiny.autoreload.pattern option. For example, to monitor only ui.R:
|
|
<code>options(shiny.autoreload.pattern = glob2rx("ui.R"))</code></p>
|
|
<p>The default polling interval is 500 milliseconds. You can change this
|
|
by setting e.g. <code>options(shiny.autoreload.interval = 2000)</code> (every
|
|
two seconds).</p></dd>
|
|
|
|
<dt>shiny.deprecation.messages (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>This controls whether messages for
|
|
deprecated functions in Shiny will be printed. See
|
|
<code><a href="shinyDeprecated.html">shinyDeprecated()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.error (defaults to <code>NULL</code>)</dt>
|
|
<dd><p>This can be a function which is called when an error
|
|
occurs. For example, <code>options(shiny.error=recover)</code> will result a
|
|
the debugger prompt when an error occurs.</p></dd>
|
|
|
|
<dt>shiny.fullstacktrace (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>Controls whether "pretty" (<code>FALSE</code>) or full
|
|
stack traces (<code>TRUE</code>) are dumped to the console when errors occur during Shiny app execution.
|
|
Pretty stack traces attempt to only show user-supplied code, but this pruning can't always
|
|
be done 100% correctly.</p></dd>
|
|
|
|
<dt>shiny.host (defaults to <code>"127.0.0.1"</code>)</dt>
|
|
<dd><p>The IP address that Shiny should listen on. See
|
|
<code><a href="runApp.html">runApp()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.jquery.version (defaults to <code>3</code>)</dt>
|
|
<dd><p>The major version of jQuery to use.
|
|
Currently only values of <code>3</code> or <code>1</code> are supported. If <code>1</code>, then jQuery 1.12.4 is used. If <code>3</code>,
|
|
then jQuery 3.6.0 is used.</p></dd>
|
|
|
|
<dt>shiny.json.digits (defaults to <code>16</code>)</dt>
|
|
<dd><p>The number of digits to use when converting
|
|
numbers to JSON format to send to the client web browser.</p></dd>
|
|
|
|
<dt>shiny.launch.browser (defaults to <code><a href="https://rdrr.io/r/base/interactive.html" class="external-link">interactive()</a></code>)</dt>
|
|
<dd><p>A boolean which controls the default behavior
|
|
when an app is run. See <code><a href="runApp.html">runApp()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.mathjax.url (defaults to <code>"https://mathjax.rstudio.com/latest/MathJax.js"</code>)</dt>
|
|
<dd><p>The URL that should be used to load MathJax, via <code><a href="withMathJax.html">withMathJax()</a></code>.</p></dd>
|
|
|
|
<dt>shiny.mathjax.config (defaults to <code>"config=TeX-AMS-MML_HTMLorMML"</code>)</dt>
|
|
<dd><p>The querystring
|
|
used to load MathJax, via <code><a href="withMathJax.html">withMathJax()</a></code>.</p></dd>
|
|
|
|
<dt>shiny.maxRequestSize (defaults to 5MB)</dt>
|
|
<dd><p>This is a number which specifies the maximum
|
|
web request size, which serves as a size limit for file uploads.</p></dd>
|
|
|
|
<dt>shiny.minified (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>By default
|
|
Whether or not to include Shiny's JavaScript as a minified (<code>shiny.min.js</code>)
|
|
or un-minified (<code>shiny.js</code>) file. The un-minified version is larger,
|
|
but can be helpful for development and debugging.</p></dd>
|
|
|
|
<dt>shiny.port (defaults to a random open port)</dt>
|
|
<dd><p>A port number that Shiny will listen on. See
|
|
<code><a href="runApp.html">runApp()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.reactlog (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, enable logging of reactive events,
|
|
which can be viewed later with the <code><a href="reactlog.html">reactlogShow()</a></code> function.
|
|
This incurs a substantial performance penalty and should not be used in
|
|
production.</p></dd>
|
|
|
|
<dt>shiny.sanitize.errors (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, then normal errors (i.e.
|
|
errors not wrapped in <code>safeError</code>) won't show up in the app; a simple
|
|
generic error message is printed instead (the error and strack trace printed
|
|
to the console remain unchanged). If you want to sanitize errors in general, but you DO want a
|
|
particular error <code>e</code> to get displayed to the user, then set this option
|
|
to <code>TRUE</code> and use <code>stop(safeError(e))</code> for errors you want the
|
|
user to see.</p></dd>
|
|
|
|
<dt>shiny.stacktraceoffset (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, then Shiny's printed stack
|
|
traces will display srcrefs one line above their usual location. This is
|
|
an arguably more intuitive arrangement for casual R users, as the name
|
|
of a function appears next to the srcref where it is defined, rather than
|
|
where it is currently being called from.</p></dd>
|
|
|
|
<dt>shiny.suppressMissingContextError (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>Normally, invoking a reactive
|
|
outside of a reactive context (or <code><a href="isolate.html">isolate()</a></code>) results in
|
|
an error. If this is <code>TRUE</code>, don't error in these cases. This
|
|
should only be used for debugging or demonstrations of reactivity at the
|
|
console.</p></dd>
|
|
|
|
<dt>shiny.testmode (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, then various features for testing Shiny
|
|
applications are enabled.</p></dd>
|
|
|
|
<dt>shiny.snapshotsortc (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, test snapshot keys
|
|
for <span class="pkg">shinytest</span> will be sorted consistently using the C locale. Snapshots
|
|
retrieved by <span class="pkg">shinytest2</span> will always sort using the C locale.</p></dd>
|
|
|
|
<dt>shiny.trace (defaults to <code>FALSE</code>)</dt>
|
|
<dd><p>Print messages sent between the R server and the web
|
|
browser client to the R console. This is useful for debugging. Possible
|
|
values are <code>"send"</code> (only print messages sent to the client),
|
|
<code>"recv"</code> (only print messages received by the server), <code>TRUE</code>
|
|
(print all messages), or <code>FALSE</code> (default; don't print any of these
|
|
messages).</p></dd>
|
|
|
|
<dt>shiny.autoload.r (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>If <code>TRUE</code>, then the R/
|
|
of a shiny app will automatically be sourced.</p></dd>
|
|
|
|
<dt>shiny.useragg (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>Set to <code>FALSE</code> to prevent PNG rendering via the
|
|
ragg package. See <code><a href="plotPNG.html">plotPNG()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.usecairo (defaults to <code>TRUE</code>)</dt>
|
|
<dd><p>Set to <code>FALSE</code> to prevent PNG rendering via the
|
|
Cairo package. See <code><a href="plotPNG.html">plotPNG()</a></code> for more information.</p></dd>
|
|
|
|
<dt>shiny.devmode (defaults to <code>NULL</code>)</dt>
|
|
<dd><p>Option to enable Shiny Developer Mode. When set,
|
|
different default <code>getOption(key)</code> values will be returned. See <code><a href="devmode.html">devmode()</a></code> for more details.</p></dd>
|
|
|
|
|
|
</dl></div>
|
|
<div id="scoping-for-shinyoptions-">
|
|
<h2>Scoping for <code>shinyOptions()</code></h2>
|
|
|
|
|
|
|
|
<p>There are three levels of scoping for <code>shinyOptions()</code>: global,
|
|
application, and session.</p>
|
|
<p>The global option set is available by default. Any calls to
|
|
<code>shinyOptions()</code> and <code>getShinyOption()</code> outside of an app will access the
|
|
global option set.</p>
|
|
<p>When a Shiny application is run with <code><a href="runApp.html">runApp()</a></code>, the global option set is
|
|
duplicated and the new option set is available at the application level. If
|
|
options are set from <code>global.R</code>, <code>app.R</code>, <code>ui.R</code>, or <code>server.R</code> (but
|
|
outside of the server function), then the application-level options will be
|
|
modified.</p>
|
|
<p>Each time a user session is started, the application-level option set is
|
|
duplicated, for that session. If the options are set from inside the server
|
|
function, then they will be scoped to the session.</p>
|
|
</div>
|
|
<div id="options-with-shinyoptions-">
|
|
<h2>Options with <code>shinyOptions()</code></h2>
|
|
|
|
|
|
|
|
<p>There are a number of global options that affect Shiny's behavior. These
|
|
can be set globally with <code><a href="https://rdrr.io/r/base/options.html" class="external-link">options()</a></code> or locally (for a single app) with
|
|
<code>shinyOptions()</code>.</p>
|
|
<dl><dt>cache</dt>
|
|
<dd><p>A caching object that will be used by
|
|
<code><a href="renderCachedPlot.html">renderCachedPlot()</a></code>. If not specified, a <code><a href="https://cachem.r-lib.org/reference/cache_mem.html" class="external-link">cachem::cache_mem()</a></code> will be
|
|
used.</p></dd>
|
|
|
|
</dl></div>
|
|
|
|
</div>
|
|
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
|
|
<nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
|
|
</nav></div>
|
|
</div>
|
|
|
|
|
|
<footer><div class="copyright">
|
|
<p></p><p>Developed by Winston Chang, Joe Cheng, JJ Allaire, Carson Sievert, Barret Schloerke, Yihui Xie, Jeff Allen, Jonathan McPherson, Alan Dipert, Barbara Borges.</p>
|
|
</div>
|
|
|
|
<div class="pkgdown">
|
|
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
|
|
</div>
|
|
|
|
</footer></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body></html>
|
|
|