我想在桌子上执行conditional formatting以便在Shinydashboard应用程序中输出(将包含一个允许pdf下载的按钮)...但是这里有捕获,我想选择依赖于细胞的颜色在另一个价值。
在我的用例中,我每年有3列,实际,目标,百分比。根据百分比(90%+,80-89,79-)的值,我想强调绿色,黄色,红色的百分比,实际值和目标列。
这是我的数据:
a <- tribble(
~Item, ~X2015_Actual, ~X2015_Target, ~X2015_Perc, ~X2016_Actual, ~X2016_Target, ~X2016_Perc,
"Item 1", 1554, 2000, 78, 2100, 2500, 84,
"Item 2", 5565, 5000, 111, 4000, 6000, 67,
"Item 3", 12, 13, 92, 12, 15, 80
)
但我不知道如何根据另一栏进行比较。有什么建议吗?
我可以用condformat来做,但这似乎不适用于Shiny?
library(condformat)
condformat(a) +
rule_fill_discrete(X2016_Actual, expression = sapply(X2016_Perc,
color.picker),colours=c("0" = "white", "1" = "red",
"2" = "lightyellow", "3" = "lightgreen")) +
rule_fill_discrete(X2016_Target, expression = sapply(X2016_Perc,
color.picker),colours=c("0" = "white", "1" = "red",
"2" = "lightyellow", "3" = "lightgreen")) +
rule_fill_discrete(X2016_Perc, expression = sapply(X2016_Perc,
color.picker),colours=c("0" = "white", "1" = "red",
"2" = "lightyellow", "3" = "lightgreen"))