I am attempting to get some conditional formatting on an created .xlsx file with R and openxlsx. Wrote the below code which has worked in the past but I am now receiving the error below. I cannot tell if this is a me problem or if openxlsx isn't correctly installed.
thanks for the help.
##define conditional formatting rules
rule1 <- rule("($O1-$T1)/$O1 < -0.1", style = createStyle(fontColour = "red"))
rule2 <- rule("($O1-$T1)/$O1 >= -0.1 & ($O1-$T1)/$O1 <= -0.15", style = createStyle(fontColour = "orange"))
rule3 <- rule("($O1-$T1)/$O1 > -0.15", style = createStyle(fontColour = "green"))
## Combine the rules using addConditionalFormatting
addConditionalFormatting(sheet, cols = "H",
rows = 1:nrow(data),
rules = list(rule1, rule2, rule3))
Error in rule("($O1-$T1)/$O1 < -0.1", style = createStyle(fontColour = "red")) : could not find function "rule"
I expected the above to add the correct formatting to the final file, but the script now stops here.