jeudi 14 octobre 2021

R Shiny: small table with checkbox columns and a scrollbar

I am trying to make a Shiny app using golem, but I am very new to this. This time I just want to make a small table with checkboxes and a scroll bar, but I am not succeeding...

This is the only thing I manage to make work so far (but even the scrollbar does not seem to show):

mod_saving_side_ui <- function(id){
  ns <- NS(id)
  tagList(
    shinyjs::useShinyjs(),
    shinyalert::useShinyalert(),

    fluidRow(
      DT::DTOutput(ns("my_marker_table"), width = "75%")
    )
 
  )
}


mod_saving_side_server <- function(id, r){
  moduleServer( id, function(input, output, session){
    ns <- session$ns

    output$my_marker_table <- DT::renderDT({
      marker_df <- data.frame(marker=LETTERS, positive="", negative="")
      marker_df$positive[1] <- "y"
      marker_df$negative[2:4] <- "y"
      marker_matrix <- as.matrix(marker_df)
      
      DT::datatable(marker_matrix, options = list(scrollY = TRUE, sDom  = '<"top">rt<"bottom">ip'), rownames = FALSE)
    })
    
  })
}

It produces this:

test

However I would like to accomplish 3 things:

  1. Have a scrollbar instead of the Previous 1 2 3 Next buttons
  2. Make the positive and negative columns have a checkbox per row
  3. Have the positive checkbox preselected for the first row A, and the negative checkbox preselected for the 2:4 rows B, C, D

How to make checkboxGroupInput work in here and the scrollbar to show? Thanks!




Aucun commentaire:

Enregistrer un commentaire