Reputation: 177
I am trying to display a greek letter delta as a symbol. The unicode and encoding can be found here.
output$text <- renderText({
HTML("Displaying greek letter delta as a symbol: \u0394")
})
This results in exactly the same string when rendered instead of a symbol. Same happens when using "Δ" or "Δ". Maybe someone knows how to correctly format text with special symbols when using HTML()
in R, or share any documentation relating this?
The desired output is: "Displaying greek letter delta as a symbol: Δ"
Here is a minimal example:
library(shiny)
ui <- fluidPage(
textOutput("text")
)
server <- function(input, output, session) {
output$text <- renderText({
HTML("Displaying greek letter delta as a symbol: \u0394")
})
}
shinyApp(ui, server)
Upvotes: 3
Views: 1197
Reputation: 2977
Important: if you need to use HTML elements such as <br>
, you will need to follow @Stéphane Laurent's comment and use renderUi()
and uiOutput()
.
library(shiny)
ui <- fluidPage(
uiOutput("text")
)
server <- function(input, output, session) {
output$text <- renderUI({
HTML("<p> Displaying greek letter delta as a symbol:<br> \u0394
</p>")
})
}
shinyApp(ui, server)
Created on 2022-06-01 by the reprex package (v2.0.1)
With:
R version 4.2.0 (2022-04-22 ucrt)
shiny_1.7.1
Running under: Windows 10 x64 (build 19044)
Upvotes: 2