r - 如何在 r 闪亮的应用程序中使用 {gtsummary} 包
问题描述
是否可以在闪亮的应用程序中使用 {gtsummary} 呈现表格?
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
在闪亮的应用程序中:->
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
tableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderTable(table1)
})
谢谢你。
解决方案
也许这就是你要找的。要在闪亮的应用程序中呈现gt
表格,您必须使用gt::gt_output
和gt::render_gt
。要使这项工作适用于您的gtsummary
表格,您必须gt
通过以下方式将其转换为表格as_gt()
:
library(shiny)
library(gtsummary)
library(gt)
# 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) %>% as_gt()
table1
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
gt_output('table')
)
)
),
server = function(input, output) {
output$table <- render_gt(table1)
})
推荐阅读
- python - tf.keras.layers.Reshape 出错。TypeError: super() 参数 1 必须是类型,而不是函数
- javascript - AADSTS50011:请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:
- ios - UIImageview not updating once camera picture is taken but when gallery image is selected, camera picture shows for a second
- gcc - 从内联 asm 将 C 数组设置为新的调用堆栈(ESP)?
- android-studio - 如何在应用程序之间同步构建变体
- html - 在 Gmail 中加载 Open Sans Google 字体
- javascript - 使用 POST 方法返回从 fetch/Axios API 获得的响应 - Node JS
- python - 我如何在尝试中使用循环代码,除了代码?
- javascript - 错误控制台告诉我替换我的“。” 到 "," 在 if 语句 (js)
- typescript - 为剩余参数中的重复交替类型定义 TypeScript 类型