| To: | "Quinn, David" <David.Quinn@nrgenergy.com> |
|---|---|
| Subject: | Re: Exchanging Indices of a Matrix |
| From: | ripley@stats.ox.ac.uk |
| Date: | Tue, 25 Jun 2002 18:48:06 +0100 (BST) |
| Cc: | <s-news@lists.biostat.wustl.edu> |
| In-reply-to: | <53173E7EC9822349ACC7FBEC177BDDDA18C34D@hqmail2.nrgenergy.com> |
On Tue, 25 Jun 2002, Quinn, David wrote:
> 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
Yes, see ?aperm.
The internal representation of an array (and also of matrices but those
only have two dimensions) is a vector, not a list. A loop is involved,
but it is done in C.
>
> 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]
> }
> }
> }
>
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Exchanging Indices of a Matrix, Sundar Dorai-Raj |
|---|---|
| Next by Date: | Re: Exchanging Indices of a Matrix, Quinn, David |
| Previous by Thread: | Re: Exchanging Indices of a Matrix, Sundar Dorai-Raj |
| Next by Thread: | MASS4 questions, nj7w |
| Indexes: | [Date] [Thread] [Top] [All Lists] |