use*_*752 7 r shiny kableextra kable
我正在尝试使电缆表具有反应性,并将其导出到闪亮的应用程序中。已经尝试在服务器内部使用renderDataTable/ renderTable,并且将输出功能作为datatableOutput/ 进行了尝试tableOutput,但是没有运气,下面是代码行。
output$tableset <- renderDataTable({
kable(spread_bole) %>%
kable_styling(font_size = 15 ,bootstrap_options = c("striped","hover", "condensed")) })
tableOutput("tableset")
Run Code Online (Sandbox Code Playgroud)
由于kable返回HTML,因此您可以使用htmlOutputin ui和renderTextin 呈现表server:
# UI component
htmlOutput("tableset")
# server component
output$tableset <- renderText({
kable(spread_bole) %>%
kable_styling(
font_size = 15,
bootstrap_options = c("striped", "hover", "condensed")
)
})
Run Code Online (Sandbox Code Playgroud)
另外,如果要使其响应用户输入,则可以将其包装为反应性表达式:
my_table <- reactive({
kable(spread_bole) %>%
kable_styling(
font_size = 15,
bootstrap_options = c("striped", "hover", "condensed")
)
})
# my_table() will call the cached table
Run Code Online (Sandbox Code Playgroud)
如果要多次使用同一张表,这将特别有用。您也可以签出eventReactive以使用特定输入来触发它。请参阅此处以获取有关Shiny中的反应性的更多信息:https : //shiny.rstudio.com/articles/reactivity-overview.html