2

I'd like to plot a table in R using tableGrob containing numbers which should display in scientific notation in math mode, such as 2.45x10⁵.

I tried using format(x,scientific=TRUE) but it only displays as 2.45e+5. If I pass theme=ttheme_default(core=list(fg_params=list(parse=TRUE))), it discards formatting for some numbers and just shows plain decimal number.

library(gridExtra)
x<-matrix(c(4.5*10^-5,2.33*10^5))
tt<-ttheme_default(core=list(fg_params=list(parse=TRUE)))
plot(tableGrob(format(x,scientific=TRUE),theme=tt))

The output shows:

4.5e-05
233000

I'd rather want:

4.50×10⁻⁵
2.33×10⁵
Martin
  • 59
  • 4
  • Thank you for the answer. I was hoping for more elegant solution than the solution given in the duplicate question. I can see that plot actually shows math number format for labels, so there must have been mechanism already in place to show the math number format for any non-label values, either thru plotmath or some built-in mechanism. – Martin Sep 18 '17 at 15:43

0 Answers0