Examples for 'gtable::gtable_add_cols'


Add new columns in specified position.

Aliases: gtable_add_cols

Keywords:

### ** Examples

library(grid)
rect <- rectGrob(gp = gpar(fill = "#00000080"))
tab <- gtable(unit(rep(1, 3), "null"), unit(rep(1, 3), "null"))
tab <- gtable_add_grob(tab, rect, t = 1, l = 1, r = 3)
tab <- gtable_add_grob(tab, rect, t = 1, b = 3, l = 1)
tab <- gtable_add_grob(tab, rect, t = 1, b = 3, l = 3)
dim(tab)
[1] 3 3
plot(tab)
plot of chunk example-gtable-gtable_add_cols-1
# Grobs will continue to span over new rows if added in the middle
tab2 <- gtable_add_cols(tab, unit(1, "null"), 1)
dim(tab2)
[1] 3 4
plot(tab2)
plot of chunk example-gtable-gtable_add_cols-1
# But not when added to left (0) or right (-1, the default)
tab3 <- gtable_add_cols(tab, unit(1, "null"))
tab3 <- gtable_add_cols(tab3, unit(1, "null"), 0)
dim(tab3)
[1] 3 5
plot(tab3)
plot of chunk example-gtable-gtable_add_cols-1

[Package gtable version 0.3.0 Index]