I try to create a drop-down list in the table, given a default value, and all possible options in the list, I would like to update the value in this way and update the data, and output a updated csv file.
This is my reproducible code:
library(shiny)
library(DT)
raw_all_dataset <- iris
shinyApp(
ui <- navbarPage("Modifier",
tabPanel("Dataset Level",
mainPanel(
fluidRow(
tags$style(type='text/css', ".selectize-input { font-size: 12px; line-height: 12px;} .selectize-dropdown { font-size: 12px; line-height: 12px; }"),
),
DT::dataTableOutput("output_dataset", width = "auto", height = "auto")
)
),
theme = shinytheme("yeti")
),
server <- function(input, output, session) {
data1 <- raw_all_dataset
for (i in 1:nrow(data1)) {
data1$FRULE[i] <- as.character(selectInput("sel_data1", "", choices = c("Keep","Drop"), selected = "Keep"))
}
output$output_dataset = DT::renderDataTable(server = FALSE, DT::datatable(
data1,
style = 'jqueryui',
extensions = 'Buttons',
options = list(dom = 'Bfrtlip',buttons = list('copy', list(extend = 'collection', buttons = list(list(extend = 'csv', filename = "deid_all_dataset"),
list(extend = 'excel', filename = "deid_all_dataset")), text = 'Save this report'))),
escape = FALSE
)
)
}
)
The difficulties I am facing is that the table is not updated simultaneously, the output csv shows that all options in the drop-down list were populated out in a same cell, rather than the wanted and the only wanted one in the cell......