How to write a function in to a ifelse formula in R?
Your functions are returning logicals, no need to compare them to IND column anymore.
#example data
DF <- data.frame(IND = c(240:243, 260, 451, 452, 454, 455))
METAL <- function(x) between(x, 241, 259) | between(x, 271, 309)
MOTOR <- function(x) x == 452 | x == 454
DF$SUB <- ifelse(METAL(DF$IND), "Metal",
ifelse(MOTOR(DF$IND), "Motor", "Other"))
DF
# IND SUB
# 1 240 Other
# 2 241 Metal
# 3 242 Metal
# 4 243 Metal
# 5 260 Other
# 6 451 Other
# 7 452 Motor
# 8 454 Motor
# 9 455 Other