乳胶在闪亮的selectInput
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了乳胶在闪亮的selectInput相关的知识,希望对你有一定的参考价值。
我想知道是否有人知道如何在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/katex@0.10.0-beta/dist/katex.min.css", integrity="sha384-9tPv11A+glH/on/wEu99NVwDPwkMQESOocs/ZGXPoIiLE8MU/qkqUcZ3zzL+6DuH",
crossorigin="anonymous"),
tags$script(src="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/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"))
以上是关于乳胶在闪亮的selectInput的主要内容,如果未能解决你的问题,请参考以下文章
并非所有给定的 selectInput 选项都以闪亮的 R 显示
R闪亮:当multiple = TRUE时selectInput()不反映变量选择
闪亮的 SelectInput 和 SelectizeInput