【问题标题】:How do I insert special character as the result of case_when in R Shiny?如何在 R Shiny 中插入特殊字符作为 case_when 的结果?
【发布时间】:2019-12-17 02:56:45
【问题描述】:

我将这段代码放入 R Shiny 中:

case_when(tesdata$note <= 10 ~ "&#8804",
tesdata$note > 10 ~ "&#8805")

如果值小于或等于 10,它应该返回 ≤,如果值大于 10,它应该返回 ≥。
但是它不会给我特殊字符,而是返回代码本身"&amp;#8804"

如何让它返回特殊字符?

【问题讨论】:

    标签: r shiny case-when


    【解决方案1】:

    您可以使用等效的 unicode。

    testdata %>% 
      mutate(
        newcolumn = case_when(
          note <= 10 ~ "\u2264",  # ≤
          note > 10  ~ "\u2265",  # ≥
          TRUE       ~ "\u2245"   # ≅
        )
      )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-24
      • 2019-08-24
      • 1970-01-01
      • 2014-07-14
      • 1970-01-01
      • 2016-11-24
      • 2023-03-10
      • 2012-04-13
      相关资源
      最近更新 更多