Use the aperm() function for transposing an array.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Jeffrey Wang Research Scientist
Insightful Corp. (206) 802-2269
-----Original Message-----
From: Quinn, David [mailto:David.Quinn@nrgenergy.com]
Sent: Tuesday, June 25, 2002 10:23 AM
To: s-news@lists.biostat.wustl.edu
Cc: Quinn, David
Subject: [S] Exchanging Indices of a Matrix
Is there an easy way to do the following without the looping? I'm guessing
not, since I think the internal representation of a matrix is as a list. --
Thanks, David
for (i in 1:x)
{
for (j in 1:y)
{
for (k in 1:z)
{
new.matrix[k,j,i] <- old.matrix[i,j,k]
}
}
}
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|