rshinydt

How to display unique row in datatable


I am creating an r shiny dashboard, I am facing issue of duplicate data displayed in datatable. How to displayed unique value in a result dataframe name "merged"

Here is the code of data table displayed on dashboard.

showRecordColumns <- c('Supplier','# Parts at Risk' , 'DAM Score', 'REL Score', 'AGI Score', 'RES Score')
  SDRMSketch = htmltools::withTags(table(
    class = 'table table-striped table-hover',
    thead(
      tr(
        th(colspan = 1, ' '),
        th(colspan = 2, 'Buyer: Suilian', class="sdrm-table-head-buyer"),
        th(colspan = 3, 'Risk Matrix', class="sdrm-table-head-risk-matrics")
      ),
      tr(
        lapply(showRecordColumns, th)
      )
    )
  ))
output$SDRM <- DT::renderDataTable(DT::datatable(merged[,showRecordColumns],
                                      container = SDRMSketch,
                                      rownames = FALSE,
                                      extensions = 'Buttons',
                                      callback=JS('$(".buttons-csv").addClass("btn btn-inline btn-dark-outline"); return table;'),
                                      options = list(
                                                      paging = TRUE,
                                                      searching = TRUE,
                                                      fixedColumns = TRUE,
                                                      autoWidth = TRUE,
                                                      ordering = TRUE,
                                                      dom='Bftrip',
                                                      buttons = list(
                                                        list(extend = "csv", 
                                                             text = "Download Current Page", 
                                                             filename = "SDRM_page",
                                                             class = "btn",
                                                             exportOptions = list(
                                                               modifier = list(page = "current")
                                                             )
                                                        ),
                                                        list(extend = "csv", text = "Download Full Results", filename = "SDRM_data",
                                                             exportOptions = list(
                                                               modifier = list(page = "all")
                                                             )
                                                        )
                                                      )
                                                      )  
                                              ) %>% formatRound(c(3:6), 2)
                                              %>% formatStyle(c(2), background = styleColorBar(range(0:100), 'lightblue'))
                                      )
    
}

don't know where to use unique condition here

enter image description here


Solution

  • Tried datatable(unique(merged[,showRecordColumns])