I am dealing with a relatively straightforward problem. Using the code below, I would like to apply bi_class function only if the condition meets: ProjectID==48. The code below, perfectly works when the if statement is removed but adding the if statement returns an error: Error in if (.) ProjectID == 48 else { : the condition has length > 1.
# here is my code:
IDD_nhmap <- IDD_nhmap %>%
if (ProjectID==48) {
bi_class(x = svi,
y = race_hisp,
style = "quantile",
dim = 3) %>%
mutate() %>%
rename(bi_class_svi_H = bi_class) %>%
relocate(svi, race_hisp, bi_class_svi_H, .after = bi_class_ACSB_B)
}