Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rShiny textOutput and Paragraph on same line

Tags:

r

shiny

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?

like image 333
Jenks Avatar asked Aug 31 '16 12:08

Jenks


2 Answers

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"))
)

)
like image 145
Batanichek Avatar answered Oct 12 '22 13:10

Batanichek


Construct everything in the server.R

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

Then in ui.R

h1(textOutput("textWithNumber"))
like image 21
Kipras Kančys Avatar answered Oct 12 '22 12:10

Kipras Kančys