在下面
gt
嵌套表中,如何更改文本颜色和大小?
我在 color
中添加了 size
和 gt
,但不起作用。任何人都可以帮忙吗?谢谢!
library(gt)
library(tidyverse)
nested_data <- diamonds %>% head(10)%>% group_by(color) %>%
summarise(x=list(x),y=list(y))
nested_data %>% gt() # result as attached image
在下面的示例中,我按
x
创建了 y
和 color
的平均值表。然后,我将平均值大于 x
的所有 4.4
值设置为红色,将 x
和 y
的平均值设置为蓝色,其中 color == "J"
.
library(gt)
library(tidyverse)
diamonds %>%
head(100)%>%
group_by(color) %>%
summarise(x=mean(x),y=mean(y)) %>%
gt() %>%
tab_style(
style = list(
cell_text(color = "red")
),
locations = cells_body(
columns = vars(x),
rows = x>4.4
)) %>%
tab_style(
style = list(
cell_text(color = "blue")
),
locations = cells_body(
columns = vars(x, y),
rows = color=="J"
))