我下面有一个简单的 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)
Run Code Online (Sandbox Code Playgroud)
结果表如下所示:
我希望在渲染的表格中的“hello”和“there”之间有一个新行。换句话说,我希望“there”位于新行,但仍与“hello”位于同一单元格内。任何帮助表示赞赏。谢谢!
亲切的问候,艾斯
使用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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1989 次 |
| 最近记录: |