Mark,

Give a look:


rres<-read.table(stdin(), head=T, sep=",")
ID,Traversed, v2
1,5,1
1,7,1
1,8,1
2,8,2
2,11,2
2,7,2
3,11,3
3,22,3
3,16,3

aggregate(rres[c("Traversed", "v2")], list(rres$ID), sum)

bests

milton

On Fri, May 1, 2009 at 5:07 PM, Altaweel, Mark R. <maltaweel@anl.gov> wrote:

> Hi,
>
> I am trying to sum column information in a list with 3 instances.
>
> For example:
>
>
> ID   Traversed           ID    Traversed      ID    Traversed
> 1      5                          1       7                    1       8
> 2      8                          2       11                  2       7
> 3      11                        3       22                  3       16
>
> What I want to do is sum the Traversed variable across all these instances
> so I can get a total value for Traversed for each ID column. So the end
> output should look like the following:
>
> ID    Traversed
> 1      20
> 2      26
> 3      49
>
> Basically, just sum up the columns by id.
>
> I am using the aggregate function, but it is not working.
>
> This is what I do:
> agW<-aggregate(rres,rres[c('ID')],sum) //rres is the list
> Error in FUN(X[[1L]], ...) : argument "INDEX" is missing, with no default
>  //the error message I get
>
> As you can see, I get the index error when I try this above.
>
> Can anyone help?
>
> Thanks in advance.
>
> Mark
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


