r - 如何在 R Shiny SelectInput 下拉列表中呈现不等式
问题描述
我使用该shinydashboard
包创建了一个 R Shiny 应用程序。selectInput
使用该函数,我似乎无法在下拉框中出现不等式或 unicode 字符。谁能帮我弄清楚如何让大于或大于或等于符号(≥)出现在下拉列表中?这是一个演示该问题的示例:
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <- shinyUI(dashboardPage(
dashboardHeader(),
dashboardSidebar(collapsed = FALSE,
selectInput("Age", "4. Select Age Group:",
c("\u2265 6 months" = "_6plus",
"&ge 6 months" = "_6plus2",
"≥ 6months" = "_6plus3",
"≥ 6months" = "_6plus3",
"6 months - 4 years" = "_6_4"))),
dashboardBody(
useShinyjs()
)
))
server <- shinyServer(function(input, output, session) {
#addClass(selector = "body", class = "sidebar-collapse")
})
shinyApp(ui = ui, server = server)
然而,这似乎没有任何尝试奏效。我会很感激任何帮助。谢谢。
解决方案
您可以使用render
选项selectizeInput
在选项名称中使用 HTML 代码:
library(shiny)
render <- "
{
option: function(data, escape){return '<div class=\"option\">'+data.label+'</div>';},
item: function(data, escape){return '<div class=\"item\">'+data.label+'</div>';}
}"
ui <- fluidPage(
selectizeInput(
"age", "Age category",
choices = c(
"≤ 6 months" = 1,
"6 months - 17 years" = 2,
"≥ 18 years" = 3
),
options = list(
render = I(render)
)
)
)
server <- function(input, output){}
shinyApp(ui, server)
推荐阅读
- sql - 防止在批量查询中除以零
- php - 更改不同文件中的vs代码中的php代码
- python - Matplotlib 乳胶格式
- sql-server - SQL Server:如何始终查询名称中包含当前日期的表
- excel - 尝试从服务器位置 (VBA) 复制工作表时,如何防止“权限被拒绝”错误?
- apache-kafka - 在 Spring Cloud Stream 中使用嵌入式 Kafka 进行集成测试时,如何立即验证消息是否已得到确认?
- netty - 为什么在 netty 4.1 中不推荐使用 UDT 传输?
- python - 如何在seaborn boxplot中的同一子组之间创建间距?
- python - 为什么在 netplan 应用后我得到错误:系统没有以 systemd 作为 init 系统(PID 1)启动。无法操作
- javascript - D3.js 在更新阶段修改 DOM