1

Using Xlsx Package in R, is there a way to highlight excel cells based on specific text of another cell? i.e. if C10 = "Cat" then highlight D10 and E10. I have seen many posts surrounding numeric values. I want to format based on text value and to the next two adjacent columns.

Working Example

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")
C.Lee
  • 67
  • 7

0 Answers0