Filter Button to Display All Data [r]

Hi All,

I am trying to create a button that will display all data in a scatter plot after the data have already been filtered using other buttons. In the example below, the button works to filter the data into group 1 and group 2, but the button for “All groups” does not display all of the data. Anyone have suggestions?

This question was asked here without response: Filter button with all option

Also on Stack Overflow: https://stackoverflow.com/questions/62630417/r-plotly-filter-button-to-display-all-data

Here is the example code.

df <- tibble(x = c(1, 4, 2, 7), y = c(3, 1, 8, 4), group = c(1, 1, 2, 2))
fig <- plot_ly(data = df, type = "scatter", mode = "markers") %>%
  add_trace(x=~x, y=~y,
            transforms = list(
              list(
                type = "filter",
                target = ~group,
                operation = 'in',
                value = unique(df$group)
              )
            )
  ) %>%
  layout(
    updatemenus = list(
      list(
        type = 'dropdown',
        active = -1,
        buttons = list(
          list(method = "restyle",
               args = list("transforms[0].value", unique(df$group)[1]),
               label = "Group 1"),
          list(method = "restyle",
               args = list("transforms[0].value", unique(df$group)[2]),
               label = "Group 2"),
          list(method = "restyle",
               args = list("transforms[0].value", unique(df$group)),
               label = "All groups")
        )
      )
    )
  )
fig