[R] gettng the row number based on column conditions
jwiley.psych at gmail.com
Sun Nov 14 10:09:08 CET 2010
You should use the logical "and", i.e., "&" to tell R that you need
condition 1 (first column equals 1) AND condition 2 (second column
equals 1) to be true:
which(X[, 1] == 1 & X[, 2] == 1)
On Sun, Nov 14, 2010 at 12:39 AM, gtg <maifeng at gmail.com> wrote:
> Hi all, I would like to get the row numbers in X where col1 and col2 are both
> I tried this:
> but it gives me the row numbers where either col1 or col2 = 1
> What should I do? Thank you.
> View this message in context: http://r.789695.n4.nabble.com/gettng-the-row-number-based-on-column-conditions-tp3041549p3041549.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Ph.D. Student, Health Psychology
University of California, Los Angeles
More information about the R-help