Reputation: 307
My fellow Shiny users! I'm having trouble rendering a Greek letter in my Shiny table output. Notice that I do know how to print a Greek letter in Shiny using the HTML function. See the code snippets below.
This is ui.R:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("A sample"),
sidebarPanel(
numericInput(
inputId = "alpha",
label = HTML("α:"),
value = 0.05,
step = 0.01
)
),
mainPanel(
plotOutput("samplePlot")
)
))
And this is server.R:
shinyServer(function(input, output) {
output$samplePlot <- renderPlot({
hist(c(1:100), main = "A Sample Plot", xlab = "Whatever")
})
})
This works fine and gives me a Greek alpha in the slider. However, I wish to have Greek letters in my table output as well, but a similar approach doesn't seem to work... See the code below.
This is ui.R:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("A sample"),
sidebarPanel(
numericInput(
inputId = "alpha",
label = HTML("α:"),
value = 0.05,
step = 0.01
)
),
mainPanel(
plotOutput("samplePlot"),
tableOutput("myTable")
)
))
And this is server.R:
shinyServer(function(input, output) {
output$samplePlot <- renderPlot({
hist(c(1:100), main = "A Sample Plot", xlab = "Whatever")
})
output$myTable <- renderTable({
data.frame(alpha = HTML("α:"), value = 3)
})
})
Any ideas on how to get the Greek alpha printed out in the alpha column of the table output. Appreciate any help!
Upvotes: 1
Views: 2817
Reputation: 158
Try
sanitize.text.function = function(x) x
as an option to renderTable,
the idea which I got from this post:
r shiny table not rendering html
Upvotes: 3