Select a dataset with an input_select().

action_select_data(g, input, datasets)

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

input

Id of the input_select() used to choose the dataset.

datasets

A key value pair list where the key is the name of the dataset as listed in the choices of the input_select().

Examples

# works in Rmarkdown
input_select(
  "selector",
  "Select a dataset",
  c("Cars", "More Cars")
)

cars1 <- cars
cars2 <- cars + c(1, -4)

g2(cars, asp(dist, speed)) %>%
  fig_point() %>%
  action_select_data(
    "selector",
    datasets = list(
      "Cars" = cars1,
      "More Cars" = cars2
    )
  )