Guest User

example shiny app

a guest
Apr 12th, 2019
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.56 KB | None | 0 0
  1. library(shiny)
  2. library(purrr)
  3.  
  4. ui <- fluidPage(
  5.   uiOutput("text_ui")
  6. )
  7.  
  8. server <- function(input, output) {
  9.   text_list <- c(
  10.     "This is the first line
  11. and this is the second.",
  12.     "Another text string
  13. consisting of two lines."
  14.   )
  15.  
  16.   format_text <- function(text) {
  17.     text <- stringr::str_replace_all(text, "(\r|\n)", "<br/>")
  18.     shinydashboard::box(text, width = NULL, style = "primary", title = "text box:")
  19.   }
  20.  
  21.   output$text_ui <- renderUI({
  22.     map(text_list, format_text) %>%
  23.       tagList()
  24.   })
  25. }
  26.  
  27. shinyApp(ui = ui, server = server)
Advertisement
Add Comment
Please, Sign In to add comment