rShiny textOutput and Paragraph on same line

谁说胖子不能爱 提交于 2020-05-08 07:43:07

问题


I'm trying to put a renderText element in the form of textOutput next to a header, but it keeps putting them on different lines.

h1('This is the number:'), textOutput(output$number)

This doesn't work either:

p(h1('This is the number:'), textOutput(output$number))

Anyone have any work arounds?


回答1:


You can do it using css

ui=shinyUI(fluidPage(
tags$head(tags$style("
                  #number{
                  display:inline
                  }")),
h1('This is the number:',style="display:inline"), textOutput("number")
)

)

server=function(input,output){
  output$number=renderText({5})
}

shinyApp(ui,server)

or

ui=shinyUI(fluidPage(
tags$head(tags$style("
                  #container * {  
   display: inline;
                     }")),
div(id="container",h1('This is the number:'), textOutput("number"))
)

)



回答2:


Construct everything in the server.R

output$textWithNumber <- renderText({ 
   paste("This is the number:", yourNumber)
})

Then in ui.R

h1(textOutput("textWithNumber"))


来源:https://stackoverflow.com/questions/39250200/rshiny-textoutput-and-paragraph-on-same-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!