Assuming DF is your data frame, try this:

   aggregate(DF[,0-1:2], DF[,1:2], sum)


On 5/4/06, YIHSU CHEN <[EMAIL PROTECTED]> wrote:
> 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
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to