Re: [R] how to reshape an array avoiding for loops

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Tue 23 Aug 2005 - 14:08:35 EST

          Have you considered "aperm"? I found this listed under "See Also" for "?t".

          spencer graves

Wladimir Eremeev wrote:

> Dear r-help,
>
> I have an array a1 with dimensions [1:660,1:65,1:25]
> I would like the first dimension to be the last one.
> That is I want and array [1:65,1:25,1:660]
>
> The only way to do this, I know, is
>
> tmp.a<-array(dim=dim(a1)[c(2,3,1)])
> for(i in 1:dim(a1)[1]) tmp.a[,,i]<-a1[i,,]
> a1<-tmp.a
> rm(tmp.a)
>
>
> Is it possible to avoid 'for' loop here?
>
> Thank you!
>
> ---
> Best regards,
> Wladimir mailto:wl@eimb.ru
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves@pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Aug 23 14:16:08 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:43:20 EST