This lesson will not cover this slightly more complicated layout scheme, but it is interesting to note what it does. If you are interested in the layout scheme for this Shiny app, read the description in the application layout guide. Experiment with changing the values of the widget functions and observe the effects. Play with each widget to get a feel for what it does. Change your own App-1/app.R script to match it, and then launch the app ( runApp("App-1"), select Run App, or use shortcuts). The app.R script below makes the app pictured above. You can find the exact arguments needed by a widget on the widget function’s help page, (e.g., ?selectInput). They include things like initial values, ranges, and increments. The remaining arguments vary from widget to widget, depending on what the widget needs to do its job. In this example, the name is “action” and the label is “Action”: actionButton("action", label = "Action") It should be a character string, but it can be an empty string "". The name should be a character string.Ī label: This label will appear with the widget in your app. The first two arguments for each widget areĪ name for the widget: The user will not see this name, but you can use it to access the widget’s value. To add a widget to your app, place a widget function in sidebarPanel or mainPanel in your ui object.Įach widget function requires several arguments. You can add widgets to your web page in the same way that you added other types of HTML content in Lesson 2. Some of these widgets are built using the Twitter Bootstrap project, a popular open source framework for building user interfaces. Help text that can be added to an input form For example, Shiny provides a function named actionButton that creates an Action Button and a function named sliderInput that creates a slider bar.Ī pair of calendars for selecting a date range Shiny comes with a family of pre-built widgets, each created with a transparently named R function. This sets up opportunities that we’ll explore in Lesson 4. When a user changes the widget, the value will change as well. Shiny widgets collect a value from your user. Widgets provide a way for your users to send messages to the Shiny app. What’s a widget? A web element that your users can interact with.
This lesson will show you how to add control widgets to your Shiny apps.