数据
df <- tibble(
x = rep(paste0( "del", 1:10 ), 100),
y = rep(paste0( "topic", 1:5 ), 200),
z = paste0("question", 1:1000),
w = 1:1000
)
代码
reactable(
df,
groupBy = c("x", "y"),
columns = list(
w = colDef(
aggregate = "mean",
style = JS(
"function(rowInfo) {
var value = rowInfo.row.extra
if (value > 500) {
var color = '#008000'
} else {
var color = '#e00000'
}
return { color: color, fontFamily: 'monospace' }
}")
)
)
)
问题
if (value > 500)
出于某种原因,当值确实大于 500 时,JS 代码不会评估为 TRUE。我错过了什么吗?为什么会这样,我该如何解决?