renderTable - descriptive statistics column doesn't appear


I want to have a table with descriptive statistics but their names does not show up in my flexdashboard.
Here is the code:

descr(dataset2(), stats = c("mean", "sd", "min", "q1", "med", "q3", "max", "iqr", "cv"), round.digits = 2, display.labels = FALSE, transpose = FALSE, style = 'rmarkdown', method = 'render')


If this one doesn't work, is there a summary table that works better in a flexdashboard?


what package is your descr() from ?

descr from descr package only takes a single param, 'x',
which is the object to be described, so I'm thinking it must be something other...

It's from summarytools


ui <- fluidPage(

server <- function(input, output, session) {
  output$mytable <- renderTable({
   m <- descr(iris, 
          stats = c("mean", "sd", "min", "q1", "med", "q3", "max", "iqr", "cv"),
          transpose = FALSE) 
   class(m) <-"matrix"
   m %>% as_tibble(rownames="Statistic")

shinyApp(ui, server)


1 Like

Do you know how to keep the same column order as input data? Because it always change for alphabetical order and I don't want that.

Thank you so much for your help!

at the point where its a regular tibble select() can be used to impose any order you want.
%>% select(names(iris))

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.