<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/shiny-1-0-1/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://blog.rstudio.org/2017/04/05/shiny-1-0-1/"> RStudio Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Shiny 1.0.1 is now available on CRAN! This release primarily includes bug fixes and minor new features.</p>
<p>The most notable additions in this version of Shiny are the introduction of the <code>reactiveVal()</code> function (like <code>reactiveValues()</code>, but it only stores a single value), and that the choices of <code>radioButtons()</code> and <code>checkboxGroupInput()</code> can now contain HTML content instead of just plain text. We’ve also added compatibility for the development version of <code>ggplot2</code>.</p>
<h2>Breaking changes</h2>
<p>We unintentionally introduced a minor breaking change in that <code>checkboxGroupInput</code> used to accept <code>choices = NULL</code> to create an empty input. With Shiny 1.0.1, this throws an error; using <code>choices = character(0)</code> works. We intend to eliminate this breakage in Shiny 1.0.2.</p>
<p>Also, the <code>selected</code> argument for <code>radioButtons</code>, <code>checkboxGroupInput</code>, and <code>selectInput</code> once upon a time accepted the name of a choice, instead of the value of a choice; this behavior has been deprecated with a warning for several years now, and in Shiny 1.0.1 it is no longer supported at all.</p>
<h2>Storing single reactive values with <code>reactiveVal</code></h2>
<p>The <code>reactiveValues</code> object has been a part of Shiny since the earliest betas. It acts like a reactive version of an environment or named list, in that you can store and retrieve values using names:</p>
<pre><code>rv &lt;- reactiveValues(clicks = 0)

observeEvent(input$button, {
 currentValue &lt;- rv$clicks
 rv$clicks &lt;- currentValue + 1
})
</code></pre>
<p>If you only have a single value to store, though, it’s a little awkward that you have to use a data structure designed for multiple values.</p>
<p>With the new <code>reactiveVal</code> function, you can now create a reactive object for a single variable:</p>
<pre><code>clicks &lt;- reactiveVal(0)

observeEvent(input$button, {
 currentValue &lt;- clicks()
 clicks(currentValue + 1)
})
</code></pre>
<p>As you can see in this example, you can read the value by calling it like a function with no arguments; and you set the value by calling it with one argument.</p>
<p>This has the added benefit that you can easily pass the <code>clicks</code> object to another function or module (no need to wrap it in a <code>reactive()</code>).</p>
<h2>More flexible <code>radioButtons</code> and <code>checkboxGroupInput</code></h2>
<p>It’s now possible to create radio button and checkbox inputs with arbitrary HTML as labels. To do so, however, you need to pass different arguments to the functions. Now, when creating (or updating) either of <code>radioButtons()</code> or <code>checkboxGroupInput()</code>, you can specify the options in one of two (mutually exclusive) ways:</p>
<ul>
<li><strong>What we’ve always had</strong>:<br>
Use the <code>choices</code> argument, which must be a vector or list. The names of each element are displayed in the app UI as labels (i.e. what the user sees in your app), and the values are used for computation (i.e. the value is what’s returned by <code>input$rd</code>, where <code>rd</code> is a <code>radioButtons()</code> input). If the vector (or list) is unnamed, the values provided are used for both the UI labels and the server values.</li>
<li><strong>What’s new and allows HTML</strong>:<br>
Use both the <code>choiceNames</code> and the <code>choiceValues</code> arguments, each of which must be an <em>unnamed</em> vector or list (and both must have the same length). The elements in <code>choiceValues</code> must still be plain text (these are the values used for computation). But the elements in <code>choiceNames</code> (the UI labels) can be constructed out of HTML, either using the <code>HTML()</code> function, or an HTML tag generation function, like <code>tags$img()</code> and <code>icon()</code>.</li>
</ul>
<p><a target="_blank" rel="nofollow" href="https://gist.github.com/bborgesr/f2c865556af3b92e6991e1a34ced2a4a">Here’s an example app</a> that demos the new functionality (in this case, we have a <code>checkboxGroupInput()</code> whose labels include the flag of the country they correspond to):</p>
<p><a target="_blank" rel="nofollow" href="https://rstudioblog.files.wordpress.com/2017/04/countries-shadow.png"><img sizes="(max-width: 267px) 100vw, 267px" data-image-description="" data-orig-file="https://rstudioblog.files.wordpress.com/2017/04/countries-shadow.png?w=456" data-orig-size="267,162" data-image-title="countries" class="wp-image-4327" data-comments-opened="1" data-recalc-dims="1" data-attachment-id="4327" data-permalink="https://blog.rstudio.org/2017/04/05/shiny-1-0-1/countries-shadow/" alt="" data-medium-file="https://rstudioblog.files.wordpress.com/2017/04/countries-shadow.png?w=456?w=267" data-large-file="https://rstudioblog.files.wordpress.com/2017/04/countries-shadow.png?w=456?w=267" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://rstudioblog.files.wordpress.com/2017/04/countries-shadow.png?w=456"></a></p>
<h2><code>ggplot2</code> > 2.2.1 compatibility</h2>
<p>The development version of <code>ggplot2</code> has some changes that break compatibility with earlier versions of Shiny. The fixes in Shiny 1.0.1 will allow it to work with any version of <code>ggplot2</code>.</p>
<h2>A note on Shiny v1.0.0</h2>
<p>In January of this year, we quietly released Shiny 1.0.0 to CRAN. A lot of work went into that release, but other than minor bug fixes and features, it was mostly laying the foundation for some important features that will arrive in the coming months. So if you’re wondering if you missed the blog post for Shiny 1.0.0, you didn’t.</p>
<h2>Full changes</h2>
<p>As always, you can view the full changelog for Shiny 1.0.1 (and 1.0.0!) in our <a target="_blank" rel="nofollow" href="https://github.com/rstudio/shiny/blob/master/NEWS.md">NEWS.md</a> file.</p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rstudioblog.wordpress.com/4325/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/rstudioblog.wordpress.com/4325/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://blog.rstudio.org/2017/04/05/shiny-1-0-1/"> RStudio Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/ISaqkMINYvY"></a></div>