Reactable package for R has introduced the capability to custom filter columns.
There are some great examples at the the above link of how to add a drop down (select) list to a specific column however I'm finding it difficult to work out how to add a default filtered value on table load.
See the below example (modified from the aforementioned link), how would I have the table load with column Manufacturer
filtered by the value Acura
?
library(reactable); library(htmltools)
data <- MASS::Cars93[, c("Manufacturer", "Model", "Type", "Price")]
reactable(
data,
filterable = TRUE,
columns = list(
Manufacturer = colDef(
filterInput = function(values, name) {
tags$select(
onchange = sprintf("Reactable.setFilter('cars-select', '%s', event.target.value)", name),
lapply(unique(values), tags$option),
style = "width: 100%; height: 28px;"
)
}
)
),
defaultPageSize = 5,
elementId = "cars-select"
)