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({
summary(data_set())
})
1 Like
I'm surprised that works at all!
-
How about using verbatimTextOutput() and renderPrint()? That would make it readable, although admittedly, it would look pretty barebones.
-
You could tidy up the data before putting it in DT.
library(magrittr)
library(stringr)
st <- summary(cars)
var <- str_trim(dimnames(st)[[2]])
stat <- str_trim(gsub(":.+$", "", st))
value <- str_trim(gsub("^.+:", "", st))
data.frame(
var = rep(var, each = nrow(st)),
stat = as.vector(stat),
value = as.vector(value),
stringsAsFactors = FALSE
)
- 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