Shiny:在 VerbatimTextOutput 中停止分词 [英] Shiny: stop word splitting in VerbatimTextOutput
问题描述
我正在尝试创建一个带有一些文本框的 Shiny 应用程序.我喜欢 verbatimTextOutput 在文本周围有一个框,但是对于稍长的文本,为了包装文本,单词会在无意义的地方被破坏.有什么方法可以阻止单词被拆分吗?下面是一个非常简单的例子.
I am trying to create a Shiny app with some text boxes. I like that the verbatimTextOutput has a box around the text, but with slightly longer text, the words get broken in meaningless places in order to wrap the text. Is there some way that I can stop the words from being split? A very simple example is below.
ui <- fluidPage(
fluidRow(column(3, offset=0, verbatimTextOutput("TxtOut")))
)
server <- function(input, output, session) {
output$TxtOut <- renderText(
"a longish text that goes over multiple lines and breaks words"
)
}
shinyApp(ui = ui, server = server)
推荐答案
由于 column
宽度设置为 3
,您的文本在输出函数中被换行.正如上面评论中所解释的,遵循 style
将防止换行,并添加一个滚动条来导航.
Because column
width is set to 3
, your text is wrapping in the output function. As explained in the comments above, following style
will prevent wrapping, and add a scroll bar to navigate.
ui <- fluidPage(
tags$head(tags$style("#TxtOut {white-space: nowrap;}")),
fluidRow(column(3, offset=0, verbatimTextOutput("TxtOut")))
)
这篇关于Shiny:在 VerbatimTextOutput 中停止分词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!