[英]R Shiny: allow line break within a row of renderTable
我在下面有一個簡單的Shiny應用程序(愚蠢的示例),它僅顯示renderTable生成的表:
library(shiny)
ui <- fluidPage(
titlePanel("Issue"),
sidebarLayout(
sidebarPanel(
),
mainPanel(
tableOutput("example")
)
)
)
server <- function(input, output) {
output$example <- renderTable({
data.frame(
"a" = 1,
"b" = paste("hello","there",sep = "\n"),
"c" = 3
)
},bordered = TRUE)
}
shinyApp(ui = ui, server = server)
結果表如下所示:
我希望在呈現的表中的“ hello”和“ there”之間有新的一行。 換句話說,我希望“ there”位於換行符上,但仍與“ hello”位於同一單元格中。 任何幫助表示贊賞。 謝謝!
ACE的問候
使用sanitize.text.function
參數(傳遞給print.xtable
)並使用HTML:
server <- function(input, output) {
output$example <- renderTable({
data.frame(
"a" = 1,
"b" = paste("hello","there",sep = "<br>"),
"c" = 3
)
},bordered = TRUE, sanitize.text.function=identity)
}
shinyApp(ui = ui, server = server)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.