[R] combined multiple observations

YIHSU CHEN yschen at jhu.edu
Thu May 4 13:06:46 CEST 2006


Dear R users:

I have a data frame as follows, where e1-e3 are indicator variables with value equal 0 or 1.  

St  County  e1 e2 e3
1   2             1   0   0
1   2             0   1   0
2   1             0   0   1
2   2             1   0   0

What I would like to do is to combine observations with same pair of "ST" and "County" together.  For example, for the St=1 and County=2, I would like to have follows:

St  County  e1 e2 e3
1   2             1   1   0

Since I have a total of more than 30000 observations, any blue force way seems to be not efficient.  Does anyone of you have experience to deal with it?

Thank you so much.


Yihsu Chen
The Johns Hopkins University




More information about the R-help mailing list