Search code examples
rcomparisonrowcol

R - Finding when a row by row comparison of 2 columns is false


I'm doing a row by row comparison of 2 columns (colA==colB), which produced:

[1]     TRUE TRUE TRUE 
 .       .    .    .
 .       .    .    .
[30054] TRUE FALSE TRUE

The majority of the results should be true. I want to find occurrence numbers of when the value was FALSE. So back the example above, I would find out that occurrence 30055 or row 30055 is FALSE.


Solution

  • Assuming your test variable is v1 in data.frame df, you could use

    which(df$v1 == FALSE)