-1

有人对 gt 表有以下问题吗?

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

这可能与R降价有关吗?

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))
4

1 回答 1

1

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

library(gt)

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

在此处输入图像描述

于 2021-04-09T05:33:28.280 回答