Skip to content

Trying to avoid a loop

2 messages · Michael Roberts, Thomas Lumley

#
Hello:

Although I could write a loop to do the following, I would like
to avoid this as it would be expensive.  Does anyone know if
there is an R function that would make this faster?

Given a 3 dimensional array, say Z with dimensions {n,l,k},  I would
like to create a matrix Y with dimensions {n,l}, each element of which
contains the position {k} with the largest element that dimension.

Many thanks,
Michael Roberts



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 23 Jan 2001, Michael Roberts wrote:

            
apply(z,c(1,2),max)

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._