Outputting multiple lines of text with renderText() in R shiny -


i want output multiple lines of text using 1 rendertext() command. however, not seem possible. example, shiny tutorial have truncated code in server.r:

shinyserver(   function(input, output) {     output$text1 <- rendertext({paste("you have selected", input$var)     output$text2 <- rendertext({paste("you have chosen range goes from",       input$range[1], "to", input$range[2])})   } ) 

and code in ui.r:

shinyui(pagewithsidebar(    mainpanel(textoutput("text1"),             textoutput("text2")) )) 

which prints 2 lines:

you have selected example have chosen range goes example range. 

is possible combine 2 lines output$text1 , output$text2 1 block of code? efforts far have failed, e.g.

output$text = rendertext({paste("you have selected ", input$var, "\n", "you have chosen range goes from", input$range[1], "to", input$range[2])}) 

anyone have ideas?

you can use renderui , htmloutput instead of rendertext , textoutput.

require(shiny) runapp(list(ui = pagewithsidebar(   headerpanel("censusvis"),   sidebarpanel(     helptext("create demographic maps        information 2010 census."),     selectinput("var",                  label = "choose variable display",                 choices = c("percent white", "percent black",                             "percent hispanic", "percent asian"),                 selected = "percent white"),     sliderinput("range",                  label = "range of interest:",                 min = 0, max = 100, value = c(0, 100))   ),   mainpanel(textoutput("text1"),             textoutput("text2"),             htmloutput("text")   ) ), server = function(input, output) {   output$text1 <- rendertext({paste("you have selected", input$var)})   output$text2 <- rendertext({paste("you have chosen range goes from",                                     input$range[1], "to", input$range[2])})   output$text <- renderui({     str1 <- paste("you have selected", input$var)     str2 <- paste("you have chosen range goes from",                   input$range[1], "to", input$range[2])     html(paste(str1, str2, sep = '<br/>'))    }) } ) ) 

note need use <br/> line break. text wish display needs html escaped use html function.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -