具有 renderText 功能的闪亮应用需要添加新行

Shiny app with renderText function need to add new line

我有一个 Shiny 应用程序,我使用 renderText() 调用。我有一些粘贴的文本,但想在它们之间添加一个新行,但是,它忽略了 \n paste/print 调用。

我试过:

print(paste("Line 1\n", "Line 2\n"))

但是,打印如下:

Line 1 Line 2

我也试过:

print(paste("Line 1", "Line 2", sep = "\n"))

并且打印与上一行相同(全部在一行上)。两个调用都包含在 output$t <- renderText({ [code here] })

想法?

试试这个:

library(shiny)

ui <- fluidPage(
  verbatimTextOutput("value"),
  htmlOutput("value2")
)

server <- function( session,input, output) {

  output$value <- renderText({
    paste("Line 1", "Line 2", sep="\n")
  })

  output$value2 <- renderUI({
    HTML(paste("Line 1", "Line 2",sep ="<br/>"))
  })
}

shinyApp(ui, server)