根据另一个单元格的文本值有条件地格式化其他列中的单元格

时间:2018-10-30 13:44:16

标签: r excel xlsx conditional-formatting r-xlsx

使用R中的Xlsx包,有没有一种方法可以基于另一个单元格的特定文本来突出显示excel单元格?也就是说,如果C10 =“猫”,则突出显示D10和E10。我看过很多关于数值的文章。我想根据文本值和接下来的两个相邻列设置格式。

工作示例

library(xlsx)

setwd('C:/Users/WORKING DIRECTORY')

animals <- c("Cat","Mice","Dog","Bird","Cat","Cat")
colors <- c("Grey","White","Black","Blue","Black","Orange")
store <- c("Pet Shop","Online","Pets Mart","Walmart","Online","Pets Mart")

df <- cbind(animals,colors,store)

write.xlsx(df, file ="test_test.xlsx",row.names = FALSE, sheetName= "Data")

0 个答案:

没有答案