Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的空格_R_Whitespace_Shinydashboard - Fatal编程技术网

R中的空格

R中的空格,r,whitespace,shinydashboard,R,Whitespace,Shinydashboard,我对闪亮仪表板中的文本有问题。我想保存原始文本格式,但shiny删除了我想保留的空白 output$frame <- renderUI({ HTML(paste( p(strong("Name and Surname:"),(" John Smith")) ) ) }) tabItem(tabName = "aaa", h2("bbb"), fluidRow

我对闪亮仪表板中的文本有问题。我想保存原始文本格式,但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")) 
                )
      ),
output$frame您可以使用
HTML(“”)
添加1个空格,使用
HTML('&emsp;')
添加1个选项卡空间。在您的代码中,它将如下所示:

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

output$frame我发现我们也可以从package
stringi
中使用
striu dup(intToUtf8(160),6)
我发现这一点很难实现。只需将style元素添加到pre-wrap中,就引入了一个额外的新行:

p(strong("Name and Surname:"),("     John Smith"),style="white-space: pre-wrap")
没有其他样式元素(边距:0等)可以解决此问题…因此,为了避免此问题,我将您的strong()转换为HTML,效果非常好:

p(HTML("<b>Name and Surname:</b>         John Smith"),style="white-space: pre-wrap")
p(HTML(“姓名和姓氏:约翰·史密斯”),style=“空白:预包装”)

Shining可能不会删除任何内容。但是HTML中的空白并没有被保留——这只是HTML的工作方式。使用CSS格式而不是空格来对齐元素。