rShiny textOutput和Paragraph在同一行

Jen*_*nks 4 r shiny

我试图将renderText元素的形式放在textOutput标头旁边​​,但它始终将它们放在不同的行上。

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

这也不起作用:

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

任何人都可以解决吗?

Bat*_*hek 10

你可以用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)
Run Code Online (Sandbox Code Playgroud)

或者

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

)
Run Code Online (Sandbox Code Playgroud)


Kip*_*čys 6

在server.R中构造所有内容

output$textWithNumber <- renderText({ 
   paste("This is the number:", yourNumber)
})
Run Code Online (Sandbox Code Playgroud)

然后在ui.R中

h1(textOutput("textWithNumber"))
Run Code Online (Sandbox Code Playgroud)

  • 这不允许每个元素具有不同的属性,例如标题级别 (2认同)