I have two reactables: one from avg_sepal
and the other from avg_petal
which are both defined in my code.
The first reactable is based on avg_sepal
which marks cells conditionally in red:
So the red cells are in the following positions:
(row 1, column 2)
and (row 3, column 2)
My question is how do you mark red in the exact same positions in another reactable avg_petal
.
Desired output:
library(tidyverse)
library(reactable)
## sepal group by
avg_sepal <- iris %>%
group_by(Species) %>%
summarise(
avg_sepal_length = mean(Sepal.Length),
avg_sepal_width = mean(Sepal.Width)
)
## petal group by
avg_petal <- iris %>%
group_by(Species) %>%
summarise(
avg_petal_length = mean(Petal.Length),
avg_petal_width = mean(Petal.Width)
)
## sepal reactable
reactable(
avg_sepal,
columns = set_names(x = colnames(avg_sepal)) %>%
keep(~ .x %in% colnames(avg_sepal)[-1]) %>%
map(~ {
colDef(
style = function(value) {
ds_color <- ifelse(between(value, 2.9, 3.5), "red", "white")
list(background = ds_color)
}
)
})
)
## petal reactable
reactable(avg_petal)