[R] selection by two unique variables

2012-05-02 Thread Ayyappa Chaturvedula
Dear Group, I am working with a large dataset where I need to select for each unique id the the unique lastpk row. Here is a sample subject: id wtdt wt lastpk 64050256 2010-09-18 275 2010-09-16 64050256 2010-09-19 277 2010-09-18 64050256

Re: [R] selection by two unique variables

2012-05-02 Thread Bert Gunter
?tapply ?with is also useful here as in (untested) with(yourdataframe, tapply(lastpk, id, unique)) -- Bert On Wed, May 2, 2012 at 7:58 AM, Ayyappa Chaturvedula ayyapp...@gmail.com wrote: Dear Group, I am working with a large dataset where I need to select for each unique id the the unique

Re: [R] selection by two unique variables

2012-05-02 Thread jim holtman
try this: x - read.table(text = id wtdt wt lastpk + + 64050256 2010-09-18 275 2010-09-16 + + 64050256 2010-09-19 277 2010-09-18 + + 64050256 2010-09-20 272 2010-09-18 + + 64050256 2010-09-21 277 2010-09-18, as.is = TRUE, header = TRUE) first -