Is it possible to render a table with {gtsummary} in a shiny app?
library(gtsummary)
# make dataset with a few variables to summarize
iris2 <- iris %>% select(Sepal.Length, Sepal.Width, Species)
# summarize the data with our package
table1 <- tbl_summary(iris2)
table1
in a Shiny app: ->
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
tableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderTable(table1)
})
Thank you.
Maybe this what you are looking for. To render a
gt
table in a shiny app you have to make use ofgt::gt_output
andgt::render_gt
. To make this work for yourgtsummary
table you have to convert it togt
table viaas_gt()
: