How to mimic `dplyr::count()` using only `plotly` transforms

I’m trying to mimic dplyr::count() using only the aggregate transofrms from plot_ly() in R.

Rather than doing something like:

library(tidyverse)
library(plotly)

iris %>%
  count(Species) %>%
  plot_ly(...)

I want to do something like:

library(plotly)

plot_ly(
  data = iris,
  type = "bar",
  x = ~Species,
  y = ?????,
  mode = "markers",
  transforms = list(
    list(
      type = "aggregate",
      groups = ~Species,
      aggregations = list(
        list(
          target = "y", func = "count", enabled = T
        )
      )
    )
  )
)

How would I be able to accomplish this?

In case anyone was curious, this seemed to work:

plot_ly(
  data = iris,
  type = "bar",
  x = ~Species,
  y = ~Species,
  transforms = list(
    list(
      type = "aggregate",
      groups = ~Species,
      aggregations = list(
        list(
          target = "y", func = "count", enabled = T
        )
      )
    )
  )
)