I would like to use DT to allow the users to modify a dataset. However, when the factor cols change (by adding or removing a factor level) the corresponding table filter remains unchanged. In the following example: if I change a Species, the new Species does not appear in the filter dropdown list. Is there a workaround? Many thanks!
library(shiny)
library(DT)
library(dplyr)
iris2=iris %>% group_by(Species) %>% filter(Petal.Length==max(Petal.Length))
ui <- fluidPage(
fluidRow(column(12, DTOutput("table"))
)
)
server <- function(input, output, session) {
output$table <- renderDT({
DT::datatable(iris2, filter = "top", editable=T)
})
}
shinyApp(ui, server)