I'm trying to fill in the background of my table using formattable. Have tried a lot of different things but cant get it working.
The data I'm dealing with is very small:
running formattable script I get a nice black and white table:
formattable(df[1:2, ],
align=c("c", "c", "c", "c"))
I'm trying to get row two to have a background colour as dictated by row 3. So for example, the first square of row two would be red, the 2nd red, the 3rd green, and the last in that row would be yellow.
Does anyone have any idea how to do this? I have been trying for hours and can't get anything working.
Thanks
EDIT:
I went with :
formattable(df[1:2, ],
align=c("c", "c", "c", "c"),
list(area(col=1, row=2) ~
color_tile(df[3,1],
df[3,1]),
area(col=2, row=2) ~
color_tile(df[3,2],
df[3,2]),
area(col=3, row=2) ~
color_tile(df[3,3],
df[3,3]),
area(col=4, row=2) ~
color_tile(df[3,4],
df[3,4])))
Maybe thats clunky not sure.. but it worked.