Re: [R] data.table query

2010-12-04 Thread Dennis Murphy
Hi: dt[, mean(A), by = 'B'] B V1 [1,] 1 1.00 [2,] 2 1.67 [3,] 3 2.33 [4,] 4 3.00 ...and I can see you've found the data.table mailing list... HTH, Dennis On Fri, Dec 3, 2010 at 3:38 PM, Santosh Srinivas santosh.srini...@gmail.com wrote: Hello Group, I need a

[R] data.table query

2010-12-03 Thread Santosh Srinivas
Hello Group, I need a modification in the data.table example to get my intended result shown below ... is there a more simple way! dt - data.table(A = rep(1:3, each=4), B = rep(1:4, each=3), C = rep(1:2, 6)) dt[, transform(.SD,D=mean(A)), by=B] The result I want is below ... which is probably

Re: [R] data.table query

2010-12-03 Thread Gabor Grothendieck
On Fri, Dec 3, 2010 at 6:38 PM, Santosh Srinivas santosh.srini...@gmail.com wrote: Hello Group, I need a modification in the data.table example to get my intended result shown below ... is there a more simple way! dt - data.table(A = rep(1:3, each=4), B = rep(1:4, each=3), C = rep(1:2, 6))