I have some relatively simple code to create a table for printing to a PDF:
library(gridExtra)
df <- head(iris)
tableGrob(df, gp = gpar(fontsize = 8), row
You could edit the grobs, as suggested in the vignette
library(gridExtra)
g <- tableGrob(iris[1:4, 1:3])
edit_cell <- function(table, row, col, name="core-fg", ...){
l <- table$layout
ids <- which(l$t %in% row & l$l %in% col & l$name==name)
for (id in ids){
newgrob <- editGrob(table$grobs[id][[1]], ...)
table$grobs[id][[1]] <- newgrob
}
table
}
g <- edit_cell(g, nrow(g), seq_len(ncol(g)), "core-fg",
gp=gpar(fontsize=15, fontface="bold"))
g <- edit_cell(g, nrow(g), seq_len(ncol(g)), "core-bg",
gp=gpar(fill="darkolivegreen1",
col = "darkolivegreen4", lwd=5))
grid.newpage()
grid.draw(g)