【发布时间】:2021-06-21 18:26:15
【问题描述】:
我希望列值根据使用可反应的另一列中的值而具有不同的颜色。这是我使用的代码,但它不会改变文本的颜色,所以我做错了,希望能得到一些帮助。
library(reactable)
iris %>%
reactable(columns = list(
Sepal.Length = colDef(
style = function(index){
if(iris$Species[index] == "setosa"){
color <- "red"
}else if(iris$Species[index] == "versicolor"){
color <- "yellow"
}else if(iris$Species[index] == "virginica"){
color <- "green"
}
}
)))
【问题讨论】:
标签: r