search for: matrixwith

Displaying 1 result from an estimated 1 matches for "matrixwith".

2008 Apr 17
1
how to use a function in aggregate which accepts matrix and outputs matrix?
...s 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...