Coloring a cell with contingent information in gt

Viewed 62

I am trying to colour the cell in each row that has the maximum value using the gt package (i.e. colour the maximum value per Type). The following fails:

df <- tibble(Type=c("a","b","c"),V2=c(7:9), V3 = c(9,8,1), V4 = c(12,31,105))
df %>% 
    gt() %>% 
    tab_style(
        style = list(
            cell_fill(color = "#D9654B")
        ),
        locations = cells_body(
            columns = vars(V2, V3, V4), # not needed if coloring all columns
            rows = max(.))
    )

Please assist with ideas.

0 Answers
Related