防止生产线中断的文本输出
Prevent textOutput from producing line break
我用 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() 不起作用,因为它只显示文本输出元素的 html 代码。
包装每个元素应该有效:
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"))
)
根据它确实有效的评论,这里是我的解决方案作为答案:
box("Species was found in ", textOutput("Count1", inline = TRUE), "of", Count2, "Sites")
没有 inline = TRUE
它将 textOuput()
放在 div
中,这样就创建了换行符。
我用 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() 不起作用,因为它只显示文本输出元素的 html 代码。
包装每个元素应该有效:
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"))
)
根据它确实有效的评论,这里是我的解决方案作为答案:
box("Species was found in ", textOutput("Count1", inline = TRUE), "of", Count2, "Sites")
没有 inline = TRUE
它将 textOuput()
放在 div
中,这样就创建了换行符。