Below is a general form of nested if-else statement using dplyr
package. So I have two questions
- What is the equivalent code using
data.table
the below form? - is there any other faster function to be replaced to
str_detect()
to speed up the below code?
# assuming we have two data frames x and y ;
x <- mutate(x, test =ifelse(x$A %in% y$A & x$B %in% y$C, "Number 1",
ifelse(str_detect(x$D,"TB"), "exclude",
ifelse(str_detect(x$D,"GL"), "exclude",
ifelse(x$E %in% y$`B`, "exclude", test))))))
my real code has 10 more ifesle in the above code line.