防止textOutput产生换行符

问题描述 投票:2回答:1

我用shinydashboard建立了一个应用程序,并试图生成一个带有(反应式)文本的盒子。我在dashboardBody中的代码是

box("Species was found in ", textOutput("Count1"), "of", Count2, "Sites")

Count1是被动的,基于UI中的用户输入。Count2是在global.R中定义的。

输出是。

Species was found in
1
of 134 Sites

那么,我如何删除换行符呢? paste()不能工作,因为它只显示textoutput元素的html代码。

r shiny line break shinydashboard
1个回答
2
投票

根据评论,它确实工作,所以这里我的解决方案作为一个答案。

box("Species was found in ", textOutput("Count1", inline = TRUE), "of", Count2, "Sites")

没有 inline = TRUE 它把 textOuput()在...中 div所以,这就产生了换行符。


1
投票

缠绕每个元素应该是可行的。

box(
    div(style="display: inline-block;","Species was found in "), 
    div(style="display: inline-block;",textOutput("Count1")), 
    div(style="display: inline-block;",paste("of", Count2, "Sites"))
)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.