2017-10-16 148 views
1

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

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")) 
       ) 
    ), 

不幸的是我得到"Name and Surname: John Smith". 我希望有"Name and Surname: John Smith"

如何解决这个问题?

+0

闪亮可能不会删除任何东西。但是HTML中的空格不会被保留 - 这只是HTML工作的方式。使用CSS格式而不是空格来对齐元素。 –

回答

1

您可以使用HTML('&nbsp;')加1个空格和HTML('&emsp;')加1个空间。在你的代码,它沃尔德如下:

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

有了这个,你得到两个空格和输出如下: enter image description here

1

我发现,我们还可以使用stri_dup(intToUtf8(160), 6)从包stringi