Re: [R] For Loop help needed

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 03 Jun 2010 12:24:39 -0400

Hi Geeti,

If d is your data.frame, the following is an option:

as.data.frame.table(with(d, tapply(Count, list(x1, x2), sum)))

HTH,
Jorge

On Thu, Jun 3, 2010 at 11:18 AM, Geeti Khan <> wrote:

> Hi,
> I have a dataset with three column like this
> x1 x2 Count
> 1 0 523
> 1 0 23
> 0 0 2
> 0 1 45
> 0 0 3
> 1 1 433
>
> I need to create a loop so that when c(x1,x2)=c(1,1), I can add the
> corresponding Counts.When c(x1,x2)=c(1,0), can add the corresponding counts
> and so on. Can anyone help me????
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 03 Jun 2010 - 16:39:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jun 2010 - 16:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive