Hello,
I'd like to know if you can help me,
# Dataframe example
Species_name <- c("Cryptocephalus aureolus" ,
"Cryptocephalus aureolus" ,
"Cryptocephalos draconica" ,
"Test testi" ,
"Cryptocephalus aureoli" ,
"Cryptocephalus pulsillus"
)
First_descriptor <- c("Seguy" ,
"Moribondi" ,
"Valder" ,
"Moribondi" ,
"Valder" ,
"Roque"
)
Is_valid <- c( "TRUE" ,
"FALSE" ,
"TRUE" ,
"TRUE" ,
"TRUE" ,
"FALSE"
)
df <- data.frame(Species_name, First_descriptor , Is_valid)
# Colouring rows under a condition using gt table library
library(gt)
library(dplyr)
df %>%
gt() %>%
cols_align(
align = c("left"),
columns = everything()
) %>%
tab_style(
style = cell_fill(color = "#9AFF9A"),
locations = cells_body(
rows = Is_valid == "FALSE")
)
I'm looking for a way to colour rows with the same colour according to the sharing of a qualitative value for a given column.
A simpler example works well when the column only contains two values, TRUE or FALSE, for example. However, when the number of possible pairs of values increases I can't figure out how to go about it.
Could you please enlighten me?
Thanks a lot