How to give breakdown of text prediction sentences in Shiny

here is a solution with css style tag in the UI, another option (that you can read about, is adding a custom CSS file)

library(shiny)

ui <- fluidPage(
 
  tags$style("#mytext {white-space: pre-line;}"),
             verbatimTextOutput("mytext")
)

server <- function(input, output, session) {
  output$mytext <- renderPrint({
    
    sentences <- rep("this is a sentence\n",5)
    length(sentences)
    cat(paste0(1:length(sentences)," ",sentences))
  })
}

shinyApp(ui, server)
1 Like