Search code examples
rstringshinyprintingescaping

Shiny: renderPrint a string without [1] and without escape characters


How do I print a string in Shiny S ...

  • without [1],
  • without the starting and ending quotation marks ",
  • and without escape characters?

Example:

library("shiny")

# Define UI ----
ui <- fluidPage(
  
  mainPanel(
    verbatimTextOutput("showstring")
  )
)

# Define server logic ----
server <- function(input, output) {

  output$showstring <- renderPrint({
    
    mystring <- "DOI (\"10.3390/ijerph15010052\")"
    
    mystring
    
  })
}

# Run the app ----
shinyApp(ui = ui, server = server)

Current (bad) outcome:

shiny output that is escaped


Solution

  • The answer (thanks to Limey in the comments) was to use renderText rather than renderPrint.