Re: [R] Looking for a better code for my problem.

2013-04-24 Thread Jorge I Velez
Try subset(Dat, AA == "A" | (AA == "B" & BB == "b")) HTH, Jorge.- On Wed, Apr 24, 2013 at 8:21 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Hello again, > > Let say I have following data: > > Dat <- structure(list(AA = structure(c(3L, 1L, 2L, 1L, 2L, 3L, 3L, 2L, > 3L, 1L, 1L,

Re: [R] Looking for a better code for my problem.

2013-04-24 Thread Rui Barradas
Hello, You can easily make of the following a one-liner. Note that the order of rows is not the same as in your code, so identical() will return FALSE. idx <- Dat[, 'AA'] == "A" | (Dat[, 'AA'] == "B" & Dat[, 'BB'] == "b") res2 <- Dat[idx, ] Hope this helps, Rui Barradas Em 24-04-2013 11:2