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),
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
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
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)
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
5 matches
Mail list logo