Click here to Skip to main content
14,428,864 members
Rate this:
Please Sign up or sign in to vote.
See more:
So I have a data frame with 2 columns that have TRUE and FALSE values.

I want to find the rows that contain TRUE for both columns in a given row, and create a vector with Boolean values, only outputting TRUE if it meets the criteria above.

E.g.
dat <- data.frame(a = c(TRUE,TRUE,FALSE), b = c(TRUE,FALSE,FALSE)
So with the code, it should output a vector with TRUE,FALSE,FALSE, since the first row contains two TRUE values, so it output TRUE while the rest output FALSE.

What I have tried:

I have tried using the apply function but don't know how to use it to extract the correct boolean values for rows that contain TRUE for both columns for each given row.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100