I want to make a table with tableGrob
function and I also want to complete rows put color but to specific rows. h.even.alpha, h.odd.alpha, v.even.alpha and v.odd.alpha are for 2 colors interspersed and not work in this case.
Thanks.
I want to make a table with tableGrob
function and I also want to complete rows put color but to specific rows. h.even.alpha, h.odd.alpha, v.even.alpha and v.odd.alpha are for 2 colors interspersed and not work in this case.
Thanks.
If you just want differing shades on the same colour (or alternating with white), you can use h.even.alpha
and h.odd.alpha
(and v.even.alpha
/v.odd.alpha
)
library(gridExtra)
grid.table(head(iris), h.even.alpha = 1, h.odd.alpha = 0,
v.even.alpha = 1, v.odd.alpha = 1)
If you want completely different colours, you can draw the table twice, with different settings for gpar.corefill
(and the corresponding alpha
values)
grid.newpage()
grid.table(head(iris), h.even.alpha = 1, h.odd.alpha = 0,
v.even.alpha = 1, v.odd.alpha = 1,
gpar.corefill = gpar(fill = 'red',col = 'white'))
grid.table(head(iris), h.even.alpha = 0, h.odd.alpha = 1,
v.even.alpha = 1, v.odd.alpha = 1,
gpar.corefill = gpar(fill = 'purple',col = 'white'))