
Dear netters, suppose I have a matrix X [1,] 'c1'  'r6' '150'[2,] 'c1'  'r4' '70'[3,] 'c1'  'r2' '20'[4,] 'c1'  'r5' '90'[5,] 'c2'  'r2' '20'[6,] 'c3'  'r1' '10'I want to apply some funciton to groups of rows by the first column.If the function is just to calculate the average X[,3], it will be easy: aggregate(as.numeric(X[,3]),by=list(X[,1]),mean)But the function I want to use is more complicated. It will take as input a matrix(X[rows in the same group,c(2,3)], do some computation, and output another matrixwith the dimension (y,3), where y depends on the input. And I'd like the resultto be a rbind of each of the subset outputs. aggregate can not do that because the function is supposed to take vectors and output scalars.How can I apply the complicated function to groups of a matrix? Thanks! Zhihua Li
_________________________________________________________________
Windows Live Photo gallery 数码相机的超级伴侣，轻松管理和编辑照片，还能制作全景美图！
http://get.live.cn/product/photo.html
	[[alternative HTML version deleted]]

