我正尝试使用knitr和DT在html markdown中打印表格,如下所示。
library(knitr)
library(DT)
my_vals = tab$Final.amplicons.nb
my_colors = ifelse(my_vals < 5000,'orange','white')
DT::datatable(tab) %>%
formatStyle(
'Final.amplicons.nb',
target = 'row',
backgroundColor = styleEqual(my_vals,my_colors)
)
没有单元格显示为橙色,尽管我的值应该为55。怎么了?
> my_vals
[1] 112123 112778 116665 19466 85371 68394 72076 81255 59810 51696 73548 86320 57003 80294 87131 73266 68088 67708 100771 90976
[21] 101821 79905 60232 49591 56402 55209 55079 85390 55 85336 55456 77793 60298 99197 64990 47017 104828 89953 100005 87908
[41] 65121 69082 64514 68753 85883 53052 95897 78756 76555 77574 72316 68203 67707 52106 59910 99580 82437 74173 55874 66525
[61] 58873 92038 102226 108297 80314 86783 63404 60277 60364 90651 81586 76373 73294 85939 43570 81557 56468 52573 62760 72203
[81] 69894 89835 49966 73430 63710 51216 49801 79938 92529 67400 89471 77138 77554 61461 77973 62236 58973 63779 72383 83147
[101] 81281 92054 5100 9572 7529
> my_colors
[1] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
[16] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "orange" "white"
[31] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
[46] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
[61] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
[76] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
[91] "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white" "white"
> packageVersion("DT")
[1] ‘0.10.1’
target='cell'.
似乎不适用于target='row'
的相同代码