Trying to use the grid.table()
function to display a table. If a value is less than 0, then display as red, otherwise, display as green if it's greater than 0. I'm having trouble locating examples of usage; I came across this page and it seems to hard-code any individual cell formatting.
So is there a way to color-code the cells without having to hard-code the exact cell reference number?
Here's some data:
structure(list(data_2018 = c(4, 3, 4, NaN, NaN, NaN),
data_2017 = c(3,
1, 1, NaN, NaN, NaN),
pilot = c(1.31578947368421, -0.0526315789473699,
1.21052631578947, NaN, NaN, NaN),
all = c(1.22222222222222,
-0.18518518518519, 1.07407407407407, NaN, NaN, NaN),
general = c(1.20833333333333,
-0.0833333333333299, 1.16666666666667, NaN, NaN, NaN)),
class = "data.frame", row.names = c(NA,
-6L))
I've used the formattable
package which works, but I need the output to be compatible with ggplot
so I'm back at square one using grid.table()