ComeçarComece de graça

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.

Este exercício faz parte do curso

Intermediate Interactive Data Visualization with plotly in R

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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
)
Editar e executar o código