我想知道是否有人知道如何在Shiny selectInput()命令中包含LaTeX代码。我想做点什么:
ui <- shinyUI(
fluidPage(
selectInput(
c("$\mu_0 \leq 3$" = "less",
"$\mu_0 \geq 3" = "more",
"$\mu_0 = 3" = "equal"
)
)
)
server <- function(input, output, session){
# server side code here...
}
shinyApp(ui = ui, server = server)
你可以使用katex。
library(shiny)
choices <- c("less", "more", "equal")
choicesNames <- c("\\\\\\mu_0 \\leq 3",
"\\\\\\mu_0 \\geq 3",
"\\\\\\mu_0 = 3")
choices <- setNames(choices, choicesNames)
ui <- shinyUI(
fluidPage(
tags$head(
tags$link(rel="stylesheet",
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css", integrity="sha384-9tPv11A+glH/on/wEu99NVwDPwkMQESOocs/ZGXPoIiLE8MU/qkqUcZ3zzL+6DuH",
crossorigin="anonymous"),
tags$script(src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js", integrity="sha384-U8Vrjwb8fuHMt6ewaCy8uqeUXv4oitYACKdB0VziCerzt011iQ/0TqlSlv8MReCm",
crossorigin="anonymous")
),
selectizeInput(
"ID",
"LABEL",
choices,
options = list(render = I("
{
item: function(item, escape) {
var html = katex.renderToString(item.label);
return '<div>' + html + '</div>';
},
option: function(item, escape) {
var html = katex.renderToString(item.label);
return '<div>' + html + '</div>';
}
}"))
)
)
)
server <- function(input, output, session){
# server side code here...
}
shinyApp(ui = ui, server = server)
这样的事情对你有帮助吗?
selectInput("mean", label = "Parameter", choices=c("\u03BC"="mu"))