Ana5
1
Hi,
I want to have a table with descriptive statistics but their names does not show up in my flexdashboard.
Here is the code:
renderTable({
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')
})
output:
If this one doesn't work, is there a summary table that works better in a flexdashboard?
Thanks!
what package is your descr() from ?
descr from descr package only takes a single param, 'x', https://cran.r-project.org/web/packages/descr/index.html
which is the object to be described, so I'm thinking it must be something other...
library(summarytools)
library(shiny)
library(tidyverse)
ui <- fluidPage(
tableOutput("mytable")
)
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
Ana5
5
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
system
Closed
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.