[R] Functions on matrix row level
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Jan 28 16:26:56 CET 2002
"Arndt, Ulrich, VF-VP" <ulrich.arndt at vodafone.de> writes:
> Hi together,
>
> I have some data in a matrix structure - say 1000 rows with 10 columns. And
> I like to do some calculations (like max, avg or min) on row level.
> The only solution I found so fare was using a loop like
>
> for (i in 1:1000) {
> max[i] <- max(matrix[I,])
> }
>
> It looks like that this is not very fast.
> Does an other way exists?
apply(matrix,1,max)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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