rimorob rimorob - 1 year ago 170
R Question

How do I fit a very wide grid.table or tableGrob to fit on a pdf page?

I have a fairly wide table (4/3 of page width) that I'm trying to print using grid.table or grid.arrange (via tableGrob) into a pdf file. The table goes beyond page boundaries and gets clipped. Is there a way to force grid.table/grid.arrange to scale the table to the print area?

Answer Source

I got this done using font sizes. Not the best solution (requires manual intervention) but maybe someone can contribute something more elegant.

termTable = tableGrob(terms, h.even.alpha=1, h.odd.alpha=1,  v.even.alpha=0.5, v.odd.alpha=1, core.just='left', rows=c(),
gpar.coretext =gpar(fontsize=8),
gpar.coltext=gpar(fontsize=10, fontface='bold'),
gpar.rowtext=gpar(fontsize=10, fontface='bold')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download