1. Recap: linked views and selector widgets
So far you've used static and animated interactive graphics to explore the space race. In this lesson, you’ll utilize linked views and selector widgets to dig into different aspects of the data. Before you begin exploring, let’s recap a few key ideas.
2. Linked views
In chapter three, you learned how to use the crosstalk package to link plotly charts. For example, we can link a bar chart of the number of launches by agency type to a line chart displaying the launches over time.
3. SharedData
To create the graphics from the previous slide, we first create a SharedData object using the command `SharedData$new(launches, key = ~agency_type)` and store this in the object `shared_launches`. Next, we pipe this SharedData object into the code for the line chart and the bar chart.
Finally, we can link the plotly charts using either subplot() or bscols().
4. Linking views with subplot()
To link the views via subplot, we first pass the bar chart and line chart to subplot, adding any options about sharing of the x- and y-axes necessary. Then, we pipe the subplot into the highlight command to facilitate linked brushing.
5. Linking views with bscols()
To link the views via bscols(), we pass the two charts into bscols, adding the highlight command to each chart to enable linked selection from either the bar chart, or the line chart.
6. highlight() options
Depending on your goals, you may need to tweak the options of the highlight function to change the on or off selection events and whether selection should be persistent.
The highlight command also allows you to add a widget to change the color of points, which is a useful tool for highlighting clusters, or to add a selectize.js widget for indirect selection of the groups you defined as the key in your SharedData object.
7. Selector widgets
The beauty of the bscols function is not just the ability to link views, but also that simple input selectors can be added to your charts without the need for shiny. Specifically, you can add checkboxes, select boxes, or sliders to filter the data displayed on your chart.
In this example, we use the filter_checkbox and filter_select functions to add two different ways to filter out groups on the chart. Remember that each selector widget needs a unique id, a user-readable label, the sharedData object and a one-sided formula specifying the column containing the values to filter on.
8. Launch vehicles
Now that we’ve reviewed some key functionality to link and filter your plotly charts, it’s time to put these ideas into practice to continue your exploration of the space race. In addition to the launches dataset, you will also bring in data about the specific space vehicles that were launched.
The `lv` dataset contains information on these launch vehicles. The entire dataset consists of 1,578 cases and 17 variables, but you will focus your attention on a subset of these variables. Specifically, you'll explore the length and diameter of these vehicles in meters, the payload capacity to low earth orbit (or leo_capacity), and their total thrust (to_thrust).
9. Let's practice!
Now, it's time to continue your exploration to put these ideas into practice.