Jgirgenrath
Jgirgenrath

Reputation: 41

R Shiny split lines of text output from renderText()

I am making a shiny app, and in the app one feature is to output text that is generated as a list of character strings.

For example, one function outputs a list of text, for example

("a", "b", "c", "d")

When I render this text, it outputs it as such

a b c d

Instead I would like the text to be rendered so that there is a line in between each value of the list, so instead it would look like

a

b

c

d

How can I accomplish this?

Upvotes: 1

Views: 1952

Answers (2)

Yanir Mor
Yanir Mor

Reputation: 711

Adding to @AndS. answer, another option would be using renderText() with htmlOutput(), and then simply paste(mylist, collapse = "<br>")

Upvotes: 0

AndS.
AndS.

Reputation: 8120

You could try:

library(shiny)
ui <- fluidPage(
    htmlOutput("mytext")
)

server <- function(input, output, session) {
    output$mytext <- renderUI({
        mylist <- c("a", "b", "c", "d")
        HTML(paste(mylist, sep = "", collapse = '<br/>'))
    })
}

shinyApp(ui, server)

Upvotes: 1

Related Questions