2
我想定制我的tableGrob中某个特定列的字体颜色。为R中的tableGrob自定义一列的字体颜色?
Here is the original table,and this is what I would like the table to look like在第五列中的零变更为“白色”
我已经在这里跟着洗礼的指示:How do I customize particular columns for a tableGrob in R?,但没有成功。
这里是我的简单的数据框:
count <- data.frame("day17" = c(17, 4, 4, 4, 3, 2),
"day27" = c(27, 4, 5, 5, 5, 1), "day37" = c(37, 5, 5, 4, 4, 3),
"day47" = c(47, 2, 1, 3, 0, 0), "day57" = c("Time (d)", 0, 0, 0, 0, 0))
继巴蒂斯特的上面的例子,我试图针对第五列指定颜色:
colours <- matrix(c("black", "white", "white", "white", "white", "white"), ncol=1, nrow=nrow(count), byrow=FALSE)
这里是产生该表的代码:
table_theme <- ttheme_minimal(core = list(fg_params=list(col=(colours))))
grid.newpage()
table <- tableGrob(count, theme = table_theme, rows=NULL, cols=NULL)
grid.draw(table)
这段代码仍然在改变行上的颜色,而不是在一个colu上根据。任何有关这个问题的帮助将不胜感激。
我是新来堆栈溢出,这是我的第一个问题,请原谅我,如果答案实际上是一个代码错误,如缺少括号等!