每个单元格R中的不同背景颜色

时间:2016-08-29 09:47:51

标签: r dataframe dt formattable

我的桌子看起来像这样:

dt <- data.frame(name = c("A","B","C"),
                 color = c("#D2B48C","#D3D3D3","#CD853F"))

如何在dt$color列显示每种背景颜色?

1 个答案:

答案 0 :(得分:2)

您可以尝试使用show_col

scales功能
DF <- data.frame(name = c("A","B","C"),
             color = c("#D2B48C","#D3D3D3","#CD853F"))

library(scales)              
scales::show_col(DF$color)

enter image description here