Ändern Sie die Textfarbe für Zellen mit TableGrob

Gibt es eine Möglichkeit, die Farbe des Texts einer Zelle bei Verwendung von tableGrob und ggplot2 individuell zu ändern?

Zum Beispiel wäre es im Code unten großartig, wenn die Zelle mit 1 blau und die Zelle mit 2 rot sein könnte, mit 3: 8 alles schwarz.

library(ggplot2)
library(grid)

mytable = as.table(matrix(c("1","2","3","4","5","6","7","8"),ncol=2,byrow=TRUE))
mytable = tableGrob(mytable,gpar.coretext = gpar(col = "black", cex = 1))
mydf = data.frame(x = 1:10,y = 1:10)

ggplot( mydf, aes(x, y)) + annotation_custom(mytable)

Antworten auf die Frage(3)

Ihre Antwort auf die Frage