In the following reproducible example, I want to filter the lines in df, where the expression of the variables gives a specific result. Lines 1 and 3 meet the requirements and must be returned. However, my first attempt was incorrect, as I used ==to compare scalars.
df <- data.frame(matrix(c(1,8,3,7,4,5,6,2,9,1,2,3,4,5,6,7,8,9,9,6,4,3,5,8,1,7,2),ncol=9,byrow=T))
df %>%
filter(X1+13*X2/X3+X4+12*X5-X6-11+X7*X8/X9-10==66)
X1 X2 X3 X4 X5 X6 X7 X8 X9
1 9 6 4 3 5 8 1 7 2
I tried to fix my mistake using the isTRUE (all.equal (...)) method, but, to my surprise, I did not get any results at all.
df %>%
filter(isTRUE(all.equal(X1+13*X2/X3+X4+12*X5-X6-11+X7*X8/X9-10,66)))
[1] X1 X2 X3 X4 X5 X6 X7 X8 X9
<0 rows> (or 0-length row.names)
How do I make this comparison?