1

I built a data table in shiny with two columns which contain check-boxes. I found this code,(dont remember exactly from where),

output$Sum_table = renderDataTable({

  SPY <- uploaded.data()

  #Display table with checkbox buttons
  df.var.names <- names(SPY)
  addCheckboxButtons <- paste0('<input type="checkbox" name="row', df.var.names, '" value="', df.var.names, '">',"")
  addCheckboxButtons1 <- paste0('<input type="checkbox" name="row', df.var.names, '" value="', df.var.names, '">',"")

  Table<-DT::datatable(cbind(df.var.names,Exclude_variables=addCheckboxButtons,
                             Choose_Target_variable=addCheckboxButtons1), 
                       options = list(orderClasses = TRUE,
                                      lengthMenu = c(5, 25, 50),
                                      pageLength = length(df.var.names), 
                                      callback = JS("function(table) {
                                                    table.on('change.dt', 'tr td input:checkbox', function() {
                                                    setTimeout(function () {
                                                    Shiny.onInputChange('rows', 
          $(this).add('tr td input:checkbox:checked').parent().siblings(':last-child').map(function() {
                                                    return $(this).text();
                                                    }).get())
                                                    }, 10); 
                                                    });
}")),escape = FALSE)
  Table
  }) 

i used this code to bulid a data table which has three columns, it's first is the variables names, the second is checkboxes column to select the variables that i want to exclude from my model (multiple), the third is checkboxes column to select the target variable(single selection). enter image description here

what i still dont know is how to access these selected checkboxes. for example:

varibles to exclude<- selected checkboxes in the second column

target variable<- selected checkbox in the third column

Does anyone knows how to do that?

Basel.D
  • 349
  • 1
  • 18

0 Answers0