R Shiny中的空白 [英] whitespace in R Shiny

查看:38
本文介绍了R Shiny中的空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Shiny Dashboard 中遇到文本问题.我想保存原始文本格式,但闪亮删除了我想保留的空格.

I have a problem with text in Shiny Dashboard. I would like to save original text formatting, but shiny removes the whitespaces I want to keep.

output$frame <- renderUI({
    HTML(paste(
               p(strong("Name and Surname:"),("     John Smith"))
               )
         )
  })


tabItem(tabName = "aaa",
        h2("bbb"),
        fluidRow(
                box(width = 6, solidHeader = TRUE, htmlOutput("frame")) 
                )
      ),

不幸的是,我得到了姓名:约翰·史密斯".我希望有 姓名:约翰·史密斯".

Unfortunately I get "Name and Surname: John Smith". I wish to have "Name and Surname: John Smith".

如何解决这个问题?

推荐答案

您可以使用 HTML('&nbsp;') 添加 1 个空格和 HTML('&emsp;') 添加 1 个制表符空间.在您的代码中,它将如下所示:

You can use HTML('&nbsp;') to add 1 whitespace and HTML('&emsp;') to add 1 tab space. In your code it wold be as follows:

output$frame <- renderUI({
        HTML(paste(
          p(strong("Name and Surname:"), HTML('&nbsp;'),HTML('&nbsp;'),"John Smith")
        )
        )
      })

有了这个,你会得到两个空格,输出看起来像这样:

With this you get two white spaces and output looks like this:

这篇关于R Shiny中的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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