Kable cell_spec条件格式无法正常工作。

时间:2018-01-09 18:53:07

标签: r dplyr r-markdown kableextra kable

grid %>%
  mutate_if(is.numeric, function(x) {format(x, digits = 2, big.mark = ",", 
decimal.mark = ".")}) %>%
  mutate(
seven_day_unique_viewers = cell_spec(seven_day_unique_viewers, italic = (Sys.Date() - as.Date(grid$debut_date, "%B %d, %Y") < 7)),
seven_day_rating = cell_spec(seven_day_rating, italic = (Sys.Date() - as.Date(grid$debut_date, "%B %d, %Y") < 7))
  ) %>%
kable(row.names=FALSE, col.names=col_names, align='c',format.args = 
list(decimal.mark = ".", big.mark = ",", justify = c("centre")),escape=TRUE) %>%
 kable_styling(bootstrap_options = c("bordered", "hover","condensed"), 
full_width = F,font_size = 13) %>%
  column_spec(2, width = "11em") %>%
  column_spec(3, width = "10em") %>%
  row_spec(row_highlight, background = "yellow")

不确定这里发生了什么,我们将不胜感激。我确认我的if条件评估正确。

0 个答案:

没有答案