1. Learn
  2. /
  3. Courses
  4. /
  5. Case Studies: Building Web Applications with Shiny in R

Exercise

Add a layout

As you have seen in previous chapters, using a layout in a Shiny app is important in order to organize the interface and make it easier to use.

The app currently has very few objects (one title, two inputs, one word cloud output) so it is still manageable without a layout. However, the app is going to grow in the next exercises and having a sidebar layout will be beneficial. It's a good idea to add a layout to your app earlier rather than later, because placing new Shiny UI elements into an existing layout is easier than rearranging a larger non-structured app later.

As is commonly done with Shiny apps and other interactive applications, the inputs will be kept in the smaller sidebar, while the main output (the word cloud) will be in the larger main panel.

Instructions

100 XP

Your next task is to add a sidebar layout to the current Shiny app. No new UI elements are to be added other than the structure for the layout. Specifically:

  • Add a sidebar layout to the UI.
  • Inside the sidebar layout, define a sidebar panel to house the two inputs.
  • Also inside the sidebar layout, define a main panel that contains the word cloud output (line 12).