I have a dataframe that looks like:
from to value sourceID targetID clustid
1 1400 1413 0.6846 3055586 3060697 1
2 323 661 0.5550 1596205 724084 1
3 323 1411 0.6817 724084 3060607 1
4 1413 1411 0.6729 3060697 3060607 1
5 1498 1411 0.6381 3111960 3060607 1
6 1478 1415 0.7423 3062164 3099199 2
7 1478 1414 0.7423 3099199 3062163 2
8 1415 1462 0.7078 3090708 3062164 2
9 1415 1463 0.7078 3062164 3090709 2
10 1462 1404 0.7078 3090708 3058341 2
11 1418 278 0.5048 3064885 612944 3
12 1418 851 0.5595 3064885 1919812 3
13 1418 1355 0.5932 3064885 3018082 3
14 1417 278 0.5048 3064884 612944 3
15 1417 851 0.5595 3064884 1919812 3
16 862 851 0.6109 1935866 1919812 3
17 525 1632 0.6565 1365467 3458397 4
18 525 506 0.6031 1365467 1312582 4
19 1445 526 0.5288 3083388 1365468 4
20 1445 1632 0.5077 3083388 3458397 4
21 1445 1271 0.7222 3083388 2933726 4
22 526 1270 0.5121 1365468 2933725 4
23 611 582 0.6245 1477137 1519842 5
24 611 567 0.6245 1519842 1450552 5
25 611 579 0.5230 1519842 1469099 5
26 582 568 0.6381 1477137 1450553 5
27 567 616 0.7150 1450552 1528881 5
28 120 121 0.7719 370873 370871 6
29 120 438 0.6054 370871 1145838 6
30 120 166 0.5995 370871 431814 6
31 121 125 0.6452 370873 374920 6
32 121 439 0.6054 370873 1145839 6
I am using formattable to create an html output.
I want to colour the background depending on the value of clustid
I first tried:
formattable(df,
list(area(col = names(df)) ~ formatter("span",
style = ~ style(color = ifelse(df$clustid %% 2, "red", "grey")))))
But this changes only the colour of the text itself.
From the limited documentation and this question Formattable based on multiple columns and some other resources I managed to cobble together the following:
formattable(df, list(area(col = names(df)) ~ formatter("span", style = ~ style("background-color" = ifelse(df$clustid %% 2, "white", "grey")))))
This produces:
Rather than highlighting the background of the words themselves, I want to highlight the entire row itself.
I would rather highlight the entire row as opposed to just an individual cell. How can this be done?
Many thanks :)
Edit: Originally included the following on color-tile however it appears this is for a gradient across rows for a specific column, so as such is not applicable in this case.
[This is Incorrect but left as to not distrub the original question]
formattable(df, list(area(1:5) ~ color_tile("transparent", "lightgray")
But of course, there is no corresponding image included to show the output, or even the test data itself...
When I try to implement this with my conditional statements I get the following error:
formattable(df, list(area(col = names(df)) ~ color_tile(ifelse(df$clustid %% 2, "white", "grey"))))
Error in grepl(if (alpha) "^#([0-9a-fA-F]{2}){3,4}$" else "^#([0-9a-fA-F]{2}){3}$", :
argument "max.color" is missing, with no default
