0

I just wondering how to change the background color of any table produced by reactablefmtr? It has a bunch of specific themes, but I need to customize the background fill. This is the dataset that I've been working with.

lele <- data.frame(
  treatment = c("P0", "P1", "P2", "P3"),
  avg_weight = c(0.1196, 0.1142, 0.1328, 0.1426),
  income = c(2392, 2284, 2656, 2852),
  pellet_cost = c(2511, 1930, 232, 1885),
  BSF_cost = c(0, 1020, 1671, 2034),
  total_cost = c(2511, 2950, 1903, 3919),
  profit_loss = c(-119, -666, 753, -1067),
  pct_profit = c(-4.96, -29.15, 28.35, -37.4)
)
lele %>% 
  mutate(color_pal = case_when(
    pct_profit > 0 ~ "#FF9900",
    TRUE ~ "#A7A9AC"
  )) %>%
  reactable(
    .,defaultColDef = colDef(headerVAlign = 'bottom', align = "center", width = 100),
    ## Add column group
    columnGroups = list(
      colGroup(name = "Cost Structure", columns = c("pellet_cost", "BSF_cost"))
    ),
    columns = list(
      treatment = colDef(width = 110, name = "Treatment",
                        style = list(borderRight = "1px solid #777")),
      avg_weight = colDef(name = "Average Weight (gr)", width = 110),
      income = colDef(name = "Income (IDR)*",
                      style = list(borderRight = "1px dashed rgba(0, 0, 0, 0.3)")),
      pellet_cost = colDef(name = "Pellet cost (IDR)**", width = 120,
                          cell = data_bars(., fill_color = "#6CCA11",
                                          text_size = 14, box_shadow = TRUE, force_outside = c(0,300))),
      BSF_cost = colDef(name = "BSF larvae Cost (IDR)***", width = 120,
                      cell = data_bars(., fill_color = "#7b4a00",
                                       text_size = 14, box_shadow = T, force_outside = c(0, 0)),
                      style = list(borderRight = "1px dashed rgba(0, 0, 0, 0.3)")),
      total_cost = colDef(name = "Total cost (IDR)"),
      profit_loss = colDef(name = "Profit/loss<br>per unit (IDR)", html = T),
      pct_profit = colDef(width = 110, name = "Profit/loss<br>percentage (%)", html = T,
                        cell = color_tiles(., color_ref = 'color_pal')),
      color_pal = colDef(show = F)
    )
  ) %>% 
    google_font(font_family = "Montserrat")

Thank you!

0 Answers0