如何在R闪亮字符串中插入新行 [英] how to insert new line in R shiny string

查看:18
本文介绍了如何在R闪亮字符串中插入新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SHILINY中,我有以下内容:

  output$sequenceText <- renderText({
    showSequence()
  })

showSequence <- reactive({
  selectedSeqs <- as.numeric(input$sequenceSelect)
  resultString <- ""
  currentString <-""

  for(i in selectedSeqs){
    currentString <- paste(i, toString(myProts[i]), sep = ":")
    resultString <- paste(resultString, currentString, sep = "
")
  }
  return(resultString)

})

但是,换行符似乎没有受到尊重。我如何修复它?

谢谢!

推荐答案

据我所知,只有两个选项可以在SHILINE中显示多行。使用verbatimTextOutput的一种方法是在您的文本周围显示一个灰色方框(个人喜好)。另一种是使用renderUIhtmlOutput来使用原始html。以下是演示结果的基本工作示例。

require(shiny)
runApp(
  list(
    ui = pageWithSidebar(
      headerPanel("multi-line test"),
      sidebarPanel(
        p("Demo Page.")
      ),
      mainPanel(
        verbatimTextOutput("text"),
        htmlOutput("text2")
      )
    ),
    server = function(input, output){

      output$text <- renderText({
        paste("hello", "world", sep="
")
      })

      output$text2 <- renderUI({
        HTML(paste("hello", "world", sep="<br/>"))
      })

    }
  )
)

这将生成下图:

这篇关于如何在R闪亮字符串中插入新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆