Reputation: 31454
Is there a way to add html text formatting (such as superscript or subscript) to the output of renderText()
. It seems that html
tags don't work in this context.
Minimal example:
library(shiny)
ui <- fluidPage(
titlePanel("Subscript test"),
mainPanel(textOutput("test"))
)
server <- function(input, output) {
output$test <- renderText("CO<sub>2</sub>")
}
shinyApp(ui = ui, server = server)
Upvotes: 3
Views: 1827
Reputation: 8127
Your code just needs the textOutput()
in the ui
section to be changed to htmlOutput()
. The latter function is specifically designed to return a reactive variable as HTML output, which allows for the usage of HTML tags among others.
More info here: https://shiny.rstudio.com/reference/shiny/0.11.1/htmlOutput.html
Upvotes: 2