Re: [R] Aggregating by a grouping

2007-12-20 Thread Moshe Olshansky
One possibility is: > x [1] "A" "B" "C" "D" "A" "C" "D" "B" > y [1] 10 11 9 8 12 4 5 7 > basic_map [[1]] [1] "A" "B" [[2]] [1] "C" "D" > a <- which(sapply(basic_map,function(u) x %in% u),arr.ind=TRUE) > aggregate(y,list(a[order(a[,1]),2]),sum) Group.1 x 1 1 40 2 2 26 > ---

Re: [R] Aggregating by a grouping

2007-12-19 Thread Henrique Dallazuanna
try this: apply(sapply(basic_map, function(x)tapply(df$Value, df$Book, sum)[x]), 2, sum) On 19/12/2007, Kondamani, Arjun (GMI - NY Corporate Bonds) <[EMAIL PROTECTED]> wrote: > Suppose I have: > > BookValue > A 10 > B 11 > C 9 > D 8 > A 12 > C 4 > D 5

Re: [R] Aggregating by a grouping

2007-12-19 Thread Richard . Cotton
> Suppose I have: > > Book Value > A 10 > B 11 > C 9 > D 8 > A 12 > C 4 > D 5 > B 7 > > I want to summarize above not by Book but by groupings of Books as in > (below) > > I have a list ... basic_map <- list(c("A",B"),c("C,D")) > Big_names <- c("A1", "A2") > Names(basi

[R] Aggregating by a grouping

2007-12-19 Thread Kondamani, Arjun (GMI - NY Corporate Bonds)
Suppose I have: BookValue A 10 B 11 C 9 D 8 A 12 C 4 D 5 B 7 I want to summarize above not by Book but by groupings of Books as in (below) I have a list ... basic_map <- list(c("A",B"),c("