gridExtra (version 0.7)

tableGrob: tableGrob

Description

create a list of text and fill grobs and calculates the sizes for a table display

Usage

tableGrob(d, rows=rownames(d), cols=colnames(d), parse=FALSE, show.rownames=TRUE,
    show.colnames=TRUE, row.just="center", col.just="center",
    core.just="center", separator="white", show.box=FALSE,
    show.csep=FALSE, show.rsep=FALSE, equal.width=FALSE,
    equal.height=FALSE, padding.h=unit(4, "mm"), padding.v=unit(4,
    "mm"), gp, gpar.coretext=gpar(col = "black", cex = 1),
    gpar.coltext=gpar(col = "black", cex = 1, fontface = "bold"),
    gpar.rowtext=gpar(col = "black", cex = 0.8, fontface = "italic"),
    h.odd.alpha=1, h.even.alpha=1, v.odd.alpha=1, v.even.alpha=1,
    gpar.corefill=gpar(fill = "grey95", col = "white"),
    gpar.rowfill=gpar(fill = "grey90", col = "white"),
    gpar.colfill=gpar(fill = "grey90", col = "white"), theme, ...)

Arguments

d
data.frame
rows
vector of row names
cols
vector of col names
parse
logical, parse labels as expressions
row.just
justification of labels
col.just
justification of labels
core.just
justification of labels
separator
colour of the border lines
show.box
logical
show.csep
logical separator for colnames
show.rsep
logical separator for rownames
equal.width
logical
equal.height
logical
padding.h
unit of horizontal margin, per cell
padding.v
unit of vertical margin, per cell
gpar.coretext
gpar() for inner text
gpar.corefill
gpar() for inner fill
gpar.coltext
gpar() for colnames text
h.odd.alpha
h.odd.alpha
h.even.alpha
h.even.alpha
v.odd.alpha
v.odd.alpha
v.even.alpha
v.even.alpha
gpar.colfill
gpar() for colnames fill
gpar.rowtext
gpar() for rownames text
gpar.rowfill
gpar() for rownames fill
show.rownames
logical
show.colnames
logical
gp
gpar
theme
theme (list of aesthetic elements)
...
passed to grob

Value

  • a grob of class table

Examples

Run this code
grid.table(head(iris), h.even.alpha=1, h.odd.alpha=1,  v.even.alpha=0.5, v.odd.alpha=1)
grid.newpage()
grid.draw(tableGrob(head(iris, 10), name="test"))
e = expression(alpha,"testing very large width", hat(beta), integral(f(x)*dx, a, b), "abc") 
grid.edit("test", cols=e, show.rownames=FALSE, rows=NULL,
gpar.corefill = gpar(fill="white", col=NA),
grep=TRUE, global=TRUE)
grid.newpage()
grid.draw(tableGrob(head(iris, 10),
show.csep=TRUE, show.rsep=TRUE, show.box=TRUE, separator="grey", name="test"))
grid.edit("test",gp=gpar(fontsize=8, lwd=2),  equal.width=TRUE, grep=TRUE, global=TRUE)
# visualize themes
lg <- lapply(c("theme.blank", "theme.default", "theme.white",  "theme.vertical",  "theme.list", "theme.black"),
function(x) tableGrob(head(iris[, 1:3]), theme=get(x)()))
grid.newpage()
do.call(grid.arrange, lg)
## timing: a bit slow due to repeated on-the-fly calculations 
pdf("test2.pdf", height=50)
print(system.time( grid.table(iris)) ) # about 12s here
dev.off()

Run the code above in your browser using DataCamp Workspace