2
I have a data.frame with 9 variables from X1 to X9. The values of these variables are double. I need to filter the lines of this data.frame that contain (Xi,Xj,Xk) == (5.2,6.3,7.1)
for example.
I was able to solve individually with the code below. But I could not write something that would allow me to perform this task by changing only the values sought. How these values can occur in any combination of variables from X1 to X9 has gotten very complicated.
vars <- c("X1","X5","X9")
cond <- c(5.2,6.3,7.1)
lfbase %>%
filter(
.data[[vars[[1]]]] == cond[[1]],
.data[[vars[[2]]]] == cond[[2]],
.data[[vars[[3]]]] == cond[[3]]
)
The example is not reproducible. Can you please, edit the question with the departure of
dput(lfbase)
or, if the base is too large,dput(head(lfbase, 20))
? And in what format are the values searched for? In a list, in a data frame? In each line the variables ofX1
toX9
must have the three values or only a few?– Rui Barradas