Home > Mobile >  How to display LaTeX symbols in Flextable (R)
How to display LaTeX symbols in Flextable (R)

Time:09-27

I have generated the following table using the Flextable package in R. I created a conditionally formatted column with LaTeX arrow symbols in it, however the symbols aren't displayed when I generate it as a flextable. Is there a way to fix this?

library(tidyverse)
library(flextable)

data.frame(one = c(10,20,30), two = c(30,20,6)) %>% 
  mutate(Trend = case_when(.[,2] == .[,1] ~ "$\\rightarrow$", .[,2] > .[,1] ~ "$\\nearrow$", TRUE ~ "$\\searrow$")) %>% 
  flextable()

enter image description here

CodePudding user response:

It may be easier to do this with unicode values for the symbols

library(dplyr)
library(flextable)
data.frame(one = c(10,20,30), two = c(30,20,6)) %>% 
  mutate(Trend = ifelse(two == one,  "\U2192", "\U2190")) %>% 
  flextable()

-output

enter image description here

  • Related