gt table 使用行过滤器为整列着色

gt table coloring full column with row filter

有没有人遇到过 gt table 的以下问题?

无论我为选项卡样式行参数设置的值如何,整个列都会被颜色参数命中。我只希望“每集付费”列在大于 33000 时将其着色为蓝色。

这会不会是 R markdown 的东西?

hip_dt_epsd_table %>% 
  rename(State = JUR_ST_ABBR_PRIM, Episodes = epsd_count, "Paid Per Episode" = pd_per_epsd, "Episodes Outlier" = epsd_outlier, 
         "Paid Per Episode Outlier" = pd_epsd_outlier, 
         "Episodes 99th Percentile" = epsd_count_99th) %>%
  gt() %>% 
  fmt_currency(columns=vars("Paid Per Episode","Paid Per Episode Outlier")) %>%
  fmt_number(columns=vars("Episodes","Episodes Outlier","Episodes 99th Percentile"),sep_mark=",", drop_trailing_zeros = TRUE) %>%
  tab_style(
    style = cell_fill(color = "lightblue"),
    locations = cells_body(
      columns = "Paid Per Episode",
      row = "Paid Per Episode" > 33000))

由于您没有提供示例,我使用了 mtcars 数据集。

library(gt)

mtcars %>%
  gt() %>%
  tab_style(style = cell_fill(color = "lightblue"),
            locations = cells_body(columns = "disp",rows = disp > 250))