BaşlayınÜcretsiz Başlayın

Adding checkboxes

Adding checkbox filters allows you to quickly "call out" a group, or set of groups, which is particularly useful when exploring how associations change between groups.

In this exercise, your task is to add a checkbox filter for the region to a scatterplot of the housing price index against homeownership in 2017.

plotly and crosstalk have already been loaded for you, and the data are stored in us2017.

Bu egzersiz

Intermediate Interactive Data Visualization with plotly in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Add a checkbox filter for region to the left of the scatterplot stored in p17.
  • Restrict the width of the checkboxes to 3 columns, and allow the plot to span the remainder of the columns.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# shared data object
shared_us <- SharedData$new(us2017, key = ~region)

# scatterplot of housing price index against homeownership
p17 <- shared_us %>%
  plot_ly(x = ~home_owners, y = ~house_price, color = ~region, height = 400) %>%
  add_markers()
  
# add a column of checkboxes for region to the left of the plot
___(___,
  ___(id = "region", label = "Region", sharedData = ___, group = ___),
  p17
)
Kodu Düzenle ve Çalıştır