Hello, it might be a very simple question but I cannot find the solution (I tried a || b, any(a,b)... but none works). My problem is: I have two vectors, a <- c(TRUE,FALSE,FALSE) b <- c(TRUE,FALSE,TRUE) and I would like to obtain a vector that indicates if it is TRUE in any of the two vectors. Hence, the desired output would be: TRUE, FALSE, TRUE Thank you in advance, Federico __________________________________________________ [[alternative HTML version deleted]]
I think I found the solution (just after sending the email). The following apparentely works: a == TRUE | b ==TRUE Regards, Federico Federico Abascal <fede_rgroup@yahoo.com> escribió: Hello, it might be a very simple question but I cannot find the solution (I tried a || b, any(a,b)... but none works). My problem is: I have two vectors, a <- c(TRUE,FALSE,FALSE) b <- c(TRUE,FALSE,TRUE) and I would like to obtain a vector that indicates if it is TRUE in any of the two vectors. Hence, the desired output would be: TRUE, FALSE, TRUE Thank you in advance, Federico __________________________________________________ [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __________________________________________________ [[alternative HTML version deleted]]
Or you can use the "&" operator:> a <- c(TRUE,FALSE,FALSE) > b <- c(TRUE,FALSE,TRUE) > a & b[1] TRUE FALSE FALSE On 5/4/07, Federico Abascal <fede_rgroup at yahoo.com> wrote:> Hello, > > it might be a very simple question but I cannot find the solution (I tried a || b, any(a,b)... but none works). My problem is: > > I have two vectors, > a <- c(TRUE,FALSE,FALSE) > b <- c(TRUE,FALSE,TRUE) > > and I would like to obtain a vector that indicates if it is TRUE in any of the two vectors. Hence, the desired output would be: TRUE, FALSE, TRUE > > Thank you in advance, > Federico > > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
Meant the "|" operator> a | b[1] TRUE FALSE TRUE>On 5/4/07, jim holtman <jholtman at gmail.com> wrote:> Or you can use the "&" operator: > > > a <- c(TRUE,FALSE,FALSE) > > b <- c(TRUE,FALSE,TRUE) > > a & b > [1] TRUE FALSE FALSE > > > On 5/4/07, Federico Abascal <fede_rgroup at yahoo.com> wrote: > > Hello, > > > > it might be a very simple question but I cannot find the solution (I tried a || b, any(a,b)... but none works). My problem is: > > > > I have two vectors, > > a <- c(TRUE,FALSE,FALSE) > > b <- c(TRUE,FALSE,TRUE) > > > > and I would like to obtain a vector that indicates if it is TRUE in any of the two vectors. Hence, the desired output would be: TRUE, FALSE, TRUE > > > > Thank you in advance, > > Federico > > > > > > __________________________________________________ > > > > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve? >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
you need: a | b Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Federico Abascal" <fede_rgroup at yahoo.com> To: "R" <r-help at stat.math.ethz.ch> Sent: Friday, May 04, 2007 1:45 PM Subject: [R] logical or for two vectors or matrices> Hello, > > it might be a very simple question but I cannot find the solution (I > tried a || b, any(a,b)... but none works). My problem is: > > I have two vectors, > a <- c(TRUE,FALSE,FALSE) > b <- c(TRUE,FALSE,TRUE) > > and I would like to obtain a vector that indicates if it is TRUE in > any of the two vectors. Hence, the desired output would be: TRUE, > FALSE, TRUE > > Thank you in advance, > Federico > > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm