[R] subtotal for same row data

2007-03-23 Thread Yuan, Qiaoping \(NIH/NIAAA\) [E]
Hi, There, I would like to subtotal the number in a specified column for all rows having the same data for specified columns. The following is the simple example: x=matrix(c(1,2,2,0.3,2,2,2,0.5,1,2,1,0.2),3,4,byrow=T) rownames(x)=c(R1,R2,R3) colnames(x)=c(C1,C2,C3,F) x C1 C2

[R] subtotal for same row data

2007-03-23 Thread Yuan, Qiaoping \(NIH/NIAAA\) [E]
Hi, There, I would like to subtotal the number in a specified column for all rows having the same data for specified columns. The following is the simple example: x=matrix(c(1,2,2,0.3,2,2,2,0.5,1,2,1,0.2),3,4,byrow=T) rownames(x)=c(R1,R2,R3) colnames(x)=c(C1,C2,C3,F) x    C1 C2 C3   F R1