Search code examples
rdplyrcase

How do I insert special character as the result of case_when in R Shiny?


I have this code I put in R Shiny :

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

It should return ≤ if the value is less than or equal to 10 and ≥ if the value is more than 10.
However it won't give me the special character and instead return the code itself "&#8804".

How do I make it return the special character?


Solution

  • You can use the unicode equivalent.

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