Search code examples
rreactable

Incorrect No of Icons Assigned in reactablefmtr icon_assign


The attached code should present the number of blue circles (between 0 and 4) based on the responseCount, but it doesn't. I can't see why.

I always want there to be 4 in total (blue + grey) even when the selection has a lower maximum.

enter image description here

library(reactable)
library(reactablefmtr)
areas <- data.frame(name = c("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"))
areas$responseCount <- round(runif(nrow(areas), min = 0, max = 1) * 4)

reactable(
  areas,
  columns = list(
    responseCount = colDef(name = "Responses",
                           cell = icon_assign(areas, buckets = 4, 
                                              show_values = "left")
    )
  )
)

Solution

  • I reported the issue where if all values are zero and buckets has not been included, it produces the wrong sign in seq 'by' argument error to the reactablefmtr package owner Kyle Cuilla.

    Kyle speedily pushed an update to dev that fixes it :)

    So now the following works...

    library(reactable)
    remotes::install_github("kcuilla/reactablefmtr", force = TRUE)
    library(reactablefmtr)
    areas <- data.frame(name = c("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"))
    areas$responseCount <- round(runif(nrow(areas), min = 0, max = 1) * 4)
    
    reactable(
      areas,
      columns = list(
        responseCount = colDef(name = "Responses",
                               cell = icon_assign(areas,
                                                  show_values = "left")
        )
      )
    )
    

    enter image description here