[R] Trying to avoid a loop
Chong Gu
chong at stat.purdue.edu
Wed Jan 24 00:15:12 CET 2001
Date: Tue, 23 Jan 2001 17:37:31 -0500
From: Michael Roberts <mroberts at ers.usda.gov>
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-r-help at stat.math.ethz.ch
Precedence: bulk
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
apply(z,c(1,2),function(x) rev(order(x)))
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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