Reputation: 12703
How to add *
or #
as math expression in the table? I asked a similar question where the solution was offered by setting parse = TRUE
in theme
parameters. However, it does not work when I use special characters like *
or #
.
Data:
df <- data.frame( a = 1:6, b = rep( letters[1:3], each = 2 ) )
df$b <- paste0(df$b,"^",rep(c('*', '#'), 3))
Code:
library( 'gridExtra' )
library( 'grid' )
tt <- ttheme_default(core=list(fg_params=list(parse=TRUE)))
tg_df <- tableGrob(d = df, theme=tt)
grid.draw(tg_df)
Output:
Expected:
Upvotes: 0
Views: 353
Reputation: 17289
You should quote those characters:
library( 'gridExtra' )
library( 'grid' )
df <- data.frame( a = 1:6, b = rep( letters[1:3], each = 2 ) )
df$b <- paste0(df$b,"^","'", rep(c('*', '#'), 3), "'")
tt <- ttheme_default(core=list(fg_params=list(parse=TRUE)))
tg_df <- tableGrob(d = df, theme=tt)
grid.draw(tg_df)
Upvotes: 2