Summary in DT packages

Hi everyone, I have problem when I'm using the Package Data.table and R initial function summary.
When I'm using summary in a DT::renderdatatable my table format is horrible and unreadable.

is there any solution to obtain a nice Table ? Thank in advance

obtain via :
output$sum<- DT:: renderDataTable({

1 Like

I'm surprised that works at all!

  1. How about using verbatimTextOutput() and renderPrint()? That would make it readable, although admittedly, it would look pretty barebones.

  2. You could tidy up the data before putting it in DT.


st <- summary(cars)
var <- str_trim(dimnames(st)[[2]])
stat <- str_trim(gsub(":.+$", "", st))
value <- str_trim(gsub("^.+:", "", st))

  var = rep(var, each = nrow(st)),
  stat = as.vector(stat),
  value = as.vector(value),
  stringsAsFactors = FALSE
  1. Are you sure you want to display this data in tabular format? Another option would be to let people use a selectInput to choose the variable they're interested in, and you can show the summary for just that particular variable.
1 Like