<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-applications-layouts-exercises-part-9/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/05/20/shiny-applications-layouts-exercises-part-9/?utm_source=rss&utm_medium=rss&utm_campaign=shiny-applications-layouts-exercises-part-9"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/time_series_exercises_part4-38.png"><img sizes="(max-width: 150px) 100vw, 150px" alt="" class="wp-image-5829" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/time_series_exercises_part4-38-150x150.png?resize=150%2C150" data-recalc-dims="1"></a><strong>Shiny Application Layouts – Update Input</strong></p>
<p>In the ninth part of our series we will see the updated input scenario. This is different from the Dynamic UI example we met in part 8, where the UI component is generated on the server and sent to the UI, where it replaces an existing UI component.</p>
<p>This part can be useful for you in two ways. </p>
<p>First of all, you can see different ways to enhance the appearance and the utility of your shiny app. </p>
<p>Secondly you can make a revision on what you learnt in <a target="_blank" rel="nofollow" href="http://www.r-exercises.com/2016/12/12/building-shiny-app-exercises-part-1/">“Building Shiny App”</a> series as we will build basic shiny staff in order to present it in the proper way.</p>
<p>Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!</p>
<p>Answers to the exercises are available <a target="_blank" rel="nofollow" href="http://r-exercises.com/2017/05/20/shiny-application-layouts-solutions-part-9/">here</a>.</p>
<p><strong>UI Context</strong></p>
<p>As always let us create the skeleton of the app.<br>
#ui.r<br>
<code>fluidPage(<br>
  titlePanel(&quot;Title&quot;),<br>
  fluidRow(<br>
    column(3,<br>
           wellPanel()),<br>
    column(3,<br>
           wellPanel()),<br>
    column(3,<br>
           wellPanel())<br>
  )<br>
)</code><br>
#server.R<br>
<code>function(input, output, clientData, session) {}</code></p>
<p><strong>Exercise 1</strong></p>
<p>Build the initial UI of your app. Give it a title, use 4 columns and one row for each one of the three well Panel that we are going to use.</p>
<p><strong>Applying reactivity</strong></p>
<p>To create a reactive context for our app we will use the <code>observe({})</code> function in our server side.</p>
<p><strong>Exercise 2</strong></p>
<p>Create reactive context. <strong>HINT</strong>: Use <code>observe({})</code>.</p>
<p><strong>“Master” Inputs.</strong></p>
<p>Now we are going to create the two inputs that control the rest of the inputs of the app. Look at the example:<br>
#ui.r<br>
<code>textInput(&quot;text_input&quot;,<br>
                       &quot;labels:&quot;,<br>
                       &quot;Some Text&quot;),<br>
             sliderInput(&quot;slider_input&quot;,<br>
                         &quot;values:&quot;,<br>
                         min = 1, max = 100, value = 50)</code><br>
#server.r<br>
<code>t_input &lt;- input$text_input<br>
    s_input &lt;- input$slider_input</code></p>
<p><strong>Exercise 3</strong></p>
<p>Create a text Input in the ui side that controls labels and then pass it to a new variable on the server side.</p>
<div>
<aside><img src="http://www.r-exercises.com/2017/05/20/shiny-applications-layouts-exercises-part-9/?utm_source=rss&utm_medium=rss&utm_campaign=shiny-applications-layouts-exercises-part-9"></aside>
<div><strong>Learn more</strong> about Shiny in the online course <a target="_blank" rel="nofollow" href="http://www.r-exercises.com/product/r-shiny-interactive-web-apps/">R Shiny Interactive Web Apps – Next Level Data Visualization</a>. In this course you will learn how to create advanced Shiny web apps; embed video, pdfs and images; add focus and zooming tools; and many other functionalities (30 lectures, 3hrs.).</div>
</div>
<p><strong>Exercise 4</strong></p>
<p>Create a slider Input in the ui side that controls values and then pass it to a new variable on the server side.</p>
<p><strong>Dependent Inputs</strong></p>
<p>Firstly let’s create a text input that changes both the label and the text.<br>
#ui.r<br>
<code>textInput(&quot;Text&quot;,  &quot;Text input:&quot;, value = &quot;text&quot;)<br>
#server.r<br>
 updateTextInput(session, &quot;Text&quot;,<br>
      label = paste(&quot;Sth&quot;, t_input),<br>
      value = paste(&quot;Sth&quot;, s_input)<br>
    )</code></p>
<p><strong>Exercise 5</strong></p>
<p>Create a text input, in the second well Panel,that changes its label and its value according to the two “Master” Inputs you created before. <strong>HINT</strong>: Use <code>updateTextInput()</code>.</p>
<p><strong>Exercise 6</strong></p>
<p>Create a slider input,in the second well Panel,that changes its label and its value according to the two “Master” Inputs you created before. <strong>HINT</strong>: Use <code>updateSliderInput()</code>.</p>
<p><strong>Exercise 7</strong></p>
<p>Create a numeric input,in the second well Panel,that changes its label and its value according to the two “Master” Inputs you created before. <strong>HINT</strong>: Use <code>updateNumericInput()</code>.</p>
<p><strong>Exercise 8</strong></p>
<p>Create a date input,in the second well Panel,that changes its label and its value according to the two “Master” Inputs you created before. <strong>HINT</strong>: Use <code>updateDateInput()</code>.</p>
<p>In order to create a Checkbox group with the same conditions as the rest of the inputs we just created we should first create a list of options like in the example below:<br>
#server.r<br>
<code>options &lt;- list()<br>
    options[[paste(&quot;option&quot;, s_input, &quot;A&quot;)]] &lt;-<br>
      paste0(&quot;option-&quot;, s_input, &quot;-A&quot;)<br>
    options[[paste(&quot;option&quot;, s_input, &quot;B&quot;)]] &lt;-<br>
      paste0(&quot;option-&quot;, s_input, &quot;-B&quot;)</code></p>
<p><strong>Exercise 9</strong></p>
<p>Create a list with three choices for your Checkbox Group. <strong>HINT</strong>: Use <code>list()</code>.</p>
<p><strong>Exercise 10</strong></p>
<p>Create a checkboxgroup input, in the third well Panel,that changes its label and its value according to the two “Master” Inputs you created before. <strong>HINT</strong>: Use <code>updateCheckboxGroupInput()</code>.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a title="Building Shiny App exercises part 4" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/01/01/building-shiny-app-exercises-part-4/">Building Shiny App exercises part 4 </a></li>
<li><a title="Building Shiny App exercises part 1" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2016/12/12/building-shiny-app-exercises-part-1/">Building Shiny App exercises part 1 </a></li>
<li><a title="Building Shiny App exercises part 3" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2016/12/25/building-shiny-app-exercises-part-3/">Building Shiny App exercises part 3 </a></li>
<li><a target="_blank" rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/">Explore all our (>1000) R exercises</a></li>
<li><a target="_blank" rel="nofollow" href="http://www.r-exercises.com/r-courses/">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-exercises.com/2017/05/20/shiny-applications-layouts-exercises-part-9/?utm_source=rss&utm_medium=rss&utm_campaign=shiny-applications-layouts-exercises-part-9"> R-exercises</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/l_DKEBk5vI8"></a></div>