【问题标题】:Using emojis in shiny selectInput widget dropdown options在闪亮的 selectInput 小部件下拉选项中使用表情符号
【发布时间】:2021-02-21 00:56:17
【问题描述】:

我有一个闪亮的 selectInput 小部件,用于选择如下气候条件

selectInput("selectedconditions", "Select Climatic Conditions :",
                c("Temperature" = "temp",
                  "Relative Humidity" = "rh",
                  "Barometric Pressure" = "pressure",
                  "Wind Speed" = "wspeed"), multiple = TRUE)

我还想在下拉菜单中显示的选项之前添加表情符号。我想为此使用Hadley Wickams emo package

我尝试使用paste0(emo::ji("sun"),"Temperature") 来生成下拉文本,但没有成功。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您可以在 {shiny} 上下文中按原样使用该包。您的问题出现了,因为您在定义 name 参数时尝试在 c() 内使用 paste。如果您改用setNames,它将起作用:

    library(shiny)
    library(emo)
    
    shinyApp(
      ui = fluidPage(
        selectInput("selectedconditions",
                    paste0("Select Climatic Conditions", emo::ji("sun")), #
                    setNames(c("temp", "rh", "pressure", "wspeed"),
                              c(paste0("Temperature", emo::ji("sun")), "Relative Humidity",
                              "Barometric Pressure", "Wind Speed")),
        multiple = TRUE)),
    
      server = function(input, output, session) {
        
      }
    )
    

    【讨论】:

      猜你喜欢
      • 2018-10-17
      • 2018-02-21
      • 2018-07-25
      • 2018-07-07
      • 1970-01-01
      • 2021-06-18
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多