You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The <strong>user interface</strong> and <strong>server</strong> communicate through IDs that we assign to inputs from the user and outputs from the server.</p>
<p></p><figcaptionclass="figure-caption">Figure 1: Shiny apps use identifiers (“id”) to link a visual element in the UI to objects on the server. The programmer chooses the names for these IDs. Here the colour (orange or blue) indicates different IDs; in a real app the orange squares would both be the same ID (e.g. <code>user_selection</code>) and the blue squares would both be a different id (e.g. <code>app_output</code>).</figcaption><p></p>
1011
1011
</figure>
1012
1012
</div>
1013
-
<p>We use an ID (<em>in orange</em>) to link the user input in the UI to the reactive values used in the server:</p>
1013
+
<p>We use an ID (<em>in orange</em>) to link the user input in the UI to the reactive values used in the server</p>
<p></p><figcaptionclass="figure-caption">Figure 2: The orange-coloured ID refers to the selection dropdown. In the UI portion it refers to the visual element the user interacts with. In the server portion it refers to the value given by the user.</figcaption><p></p>
1022
1022
</figure>
1023
1023
</div>
1024
1024
<p>We use another ID (<em>in blue</em>) to link the output created in the server to the output shown in the user interface:</p>
<p><imgsrc="images/app-ids.png" class="img-fluid figure-img" alt="app-ids"><imgsrc="images/app_01_simple_output.png" class="img-fluid figure-img" alt="app_01_simple"> The blue-coloured ID refers to the network figure. In the UI portion it refers to the plot image that the user sees. In the server portion it refers to the R object created by the <code>renderSomething</code> function.</p>
<p>These elements can all be placed in one script named <code>app.R</code> or separately in scripts named <code>ui.R</code> and <code>server.R</code>. The choice is up to you, although it becomes easier to work in separate <code>ui.R</code> and <code>server.R</code> scripts when the Shiny app becomes more complex.</p>
1030
-
<p><strong>Example 1: Everything in <code>app.R</code></strong></p>
1031
-
<p><imgsrc="images/app-in1.png" class="img-fluid"><strong>Example 2: Split things into <code>ui.R</code> and <code>server.R</code></strong></p>
<figcaptionclass="figure-caption">Example 2: Split things into <code>ui.R</code> and <code>server.R</code></figcaption>
1055
+
</figure>
1056
+
</div>
1057
+
</div>
1058
+
</div>
1059
+
<p></p><figcaptionclass="figure-caption">Figure 4: Shiny apps can be created in a single file or split into two for easier organization</figcaption><p></p>
0 commit comments