s-news
[Top] [All Lists]

Re: Exchanging Indices of a Matrix

To: "Quinn, David" <David.Quinn@nrgenergy.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Exchanging Indices of a Matrix
From: "Jeffrey Wang" <jwang@insightful.com>
Date: Tue, 25 Jun 2002 11:05:22 -0700
Thread-index: AcIcbO+6Gk3JGvv3RMGKsN2lyuVFgAABb+1Q
Thread-topic: Exchanging Indices of a Matrix
        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


<Prev in Thread] Current Thread [Next in Thread>