I would like to apply a style to one of the vectors in a reactable output; yet some of my dataframes include some NA values and ColDef(... style function(value)) [see code below] seems to not allow to exclude NA or apply specific format to these records.
I have tried to add an else to the code below, using na.omit but cannot find a good solution (except forcing NA to 0 for ex). Any suggestion? Thanks!
reac0 <-
reactable(prod0,
columns = list(
yrmon = colDef(name = "Period", style = cell_style(font_weight="bold")),
Growth_Memb = colDef(name = "Members' Growth", format = colFormat(percent = TRUE, digits = 1),
**style = function(value) {
color <- if (value >= 0) {
"#008000"
} else if (value < 0) {
"#e00000"
}
{
list(color = color)
}
}**
)),
theme = nytimes(),
defaultPageSize = 12,
pagination = FALSE
)