Reduce space (margin) between 2 tables in gridExtra with R -



Reduce space (margin) between 2 tables in gridExtra with R -

example:

sample <- data.frame(a=c(1,2,3),b=c(2,3,4),c=c("name1","name2","name3"),d=c(1,2,3)) pdf(path,width=15,height=11) par(mfrow=c(2,1)) plot.new() vps <- baseviewports() pushviewport(vps$figure) vp1 <-plotviewport() grid.table(sample,gpar.coretext=gpar(fontsize = 14),gpar.coltext = gpar(fontsize = 14), gpar.rowtext = gpar(fontsize = 14),gpar.corefill = gpar(fill = "steelblue2", alpha = 0.4, col = na), h.even.alpha = 0.4,equal.width = false,show.rownames = false,show.vlines = true, padding.h = unit(8, "mm"),padding.v = unit(8, "mm")) # table width/height grid.text("some text comes here ...", x = 0.5, y = 0.75, gp = gpar(fontsize = 12)) popviewport() plot.new() par(mar=c(rep(0,4)+0.1)) # no effect here vps <- baseviewports() pushviewport(vps$figure) vp1 <-plotviewport() grid.table(sample,gpar.coretext=gpar(fontsize = 14),gpar.coltext = gpar(fontsize = 14), gpar.rowtext = gpar(fontsize = 14),gpar.corefill = gpar(fill = "steelblue2", alpha = 0.4, col = na), h.even.alpha = 0.4,equal.width = false,show.rownames = false,show.vlines = true, padding.h = unit(8, "mm"),padding.v = unit(8, "mm")) # table width/height grid.text("some text comes here ...", x = 0.5, y = 0.75, gp = gpar(fontsize = 12)) popviewport() dev.off()

how remove spacing between 2 tables?

edit: other more simple way:

sample <- data.frame(a=c(1,2,3),b=c(2,3,4),c=c("name1","name2","name3"),d=c(1,2,3)) pdf(path,width=5,height=4) grid.arrange(tablegrob(sample, show.rownames=f),tablegrob(sample, show.rownames=f),nrow=2) dev.off()

by playing pdf width/height 1 can cut down gap, right way of doing it?

r

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -