我有以下数据框:
col1 <- rep(c("A","B","C","D"),10)
col2 <- rep(c(1,0),10)
col3 <- rep(c(0,1),10)
col4 <- rep(c(1,0),10)
col5 <- rep(c(0,1),10)
test_df <- data.frame(col1, col2, col3, col4, col5, stringsAsFactors = F)
Run Code Online (Sandbox Code Playgroud)
我想根据 col1 中的值为多列中的特定行单元格着色,并在表中的两列之间添加一条垂直线(表示限制)(基于 col1 中的相同值)
例如,如果 col1 == "A",那么我想将 col2 和 col5 中的单元格着色为灰色,与 col1 == A 位于同一行。
在虚拟代码中:
if col1 == A: color columns(col2, col5), vert.line between col3 and col4
if col1 == B: color columns(col2, col3, col5), vert.line between col4 and col5
if col1 == C: color columns(col2, col4, col5), vert.line between col3 …Run Code Online (Sandbox Code Playgroud)