Re: [R] subsetting by groups, with conditions

2009-12-29 Thread baptiste auguie
Hi, I think you can also use plyr for this, dft - read.table(textConnection(P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4),

[R] subsetting by groups, with conditions

2009-12-28 Thread Seth W Bigelow
I have a data set similar to this: P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4 For each group of Poly1id records, I wish to

Re: [R] subsetting by groups, with conditions

2009-12-28 Thread jim holtman
try this: x - read.table(textConnection(P1idVeg1Veg2AreaPoly2 P2ID + 1 p p 1 1 + 1 p p 1.5 2 + 2 p p 2 3 + 2 p h 3.5 4), header=TRUE, as.is=TRUE) # split the

Re: [R] subsetting by groups, with conditions

2009-12-28 Thread Gabor Grothendieck
Assuming your data frame is called DF we can use sqldf like this. The inner select calculates the maximum AreaPoly2 for each group such that Veg1 = Veg2 and the outer select returns the corresponding row. library(sqldf) sqldf(select * from DF a where AreaPoly2 = (select max(AreaPoly2)

Re: [R] subsetting by groups, with conditions

2009-12-28 Thread David Winsemius
On Dec 28, 2009, at 7:03 PM, Seth W Bigelow wrote: I have a data set similar to this: P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5