有没有办法为 r shiny 的 dataTableOutput 中的特定行着色?
我发现我可以将 orderClasses = TRUE 设置为按颜色排序的列,但我想始终为输出数据表的第 2 列和第 2 行着色。我一直在阅读选项手册,但没有找到任何东西。
- - - - - -编辑 - - - - - - -
好的,所以在 Yihui 和 user5029763 的建议之后,我现在可以使用 DT 突出显示列,但我仍然无法突出显示行。这是我使用 iris 数据集作为示例的代码 - 如果 Species 是 setosa,我会尝试突出显示整行,但是,在我的计算机上,它只突出显示 setosa 的单元格:
datatable(iris) %>% formatStyle(
'Species',
target = 'row',
backgroundColor = styleEqual('setosa', 'gray')
)
- - - - 编辑 - - - - - - - - - - - -
对不起,很长的帖子 - 事实上,我运行了这里指定的确切代码:http ://rstudio.github.io/DT/010-style.html
library(DT)
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
datatable(df) %>% formatStyle(
'V6',
target = 'row',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)
它仍然只突出显示单元格而不是我计算机上的行。我使用的是 3.2.1 版的 R 和 0.99.447 版的 RStudio。我也有闪亮的 github 版本,不确定这是否会覆盖数据表中的任何选项?