[R] Re: tapply for matrices
Ott Toomet
otoomet at econ.dk
Fri Oct 11 08:32:56 CEST 2002
I have made a similar simple routine for my own purposes. I have not
compared the speed. Is there any good reason not to add something
similar to the base package, perhaps as a method for tapply?
Ott
----------------------------
tmapply <- function(X, INDEX, FUN=sum, ...) {
### tapply a function over a columns of a matrix
tvapply <- function(X, ...) {
## apply the function for a (column) vector
tapply(X, INDEX, FUN, ...)
}
apply(X, 2, FUN=tvapply, ...)
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list