Link to original text:http://tecdat.cn/?p=6154

Occasionally I want to draw a table next to the chart in R, for example, showing summary statistics for the chart itself. Very simple. The tableGrob function creates a curve chart like a data frame that is displayed on the web page of the GGploT2 graphics object.

Here’s a small example:

p+ + annotation_custom(grob = tableGrob(table, rows = NULL), + ymin = 7.5,ymax = 14)+ + theme(axis. Text = element_text(size = 14), + axis. Title = element_text(size = 16))

Session information

R Version 3.2.1 (2015-06-18) Platform: x86_64-apple-Darwin13.4.0 (64-bit) Running under: OS X 10.10.4 (Yosemite) Locale: \[1\] en\_GB.UTF-8/en\_GB.UTF-8/en\_GB.UTF-8/C/en\_GB.UTF-8/en_GB.UTF-8 attached base packages: \[1\] stats graphics grDevices utils datasets methods \[7\] base other attached packages: \[1\] gridExtra\_2.0.0 ggplot2\_1.0.1 Loaded via a namespace (and not attached): \ [1 \] Rcpp \ _0. 11.6 digest \ _0 6.8 MASS_7. 3-42 \ [4 \] the grid \ _3 2.1 plyr \ _1 gtable_0. 8.3 1.2 \ [7 \] magrittr \ _1. 5 Scales \_0.2.5 stringi_0.5-5 \[10\] Reshape2 \_1.4.1 proto\_0.3-10 Labeling_0.3 \[13\] Tools \_3.2.1 stringr\_1.0.0 Munsell_0. 4.2 \ [16 \] colorspace_1. 2-6