[R] array manipulation
David Winsemius
dwinsemius at comcast.net
Wed Nov 2 20:15:53 CET 2011
On Nov 2, 2011, at 12:16 PM, Simone Salvadei wrote:
> Hello,
> I'm at the very beginning of the learning process of this language.
> Sorry in advance for the (possible but plausible) stupidity of my
> question.
>
> I would like to find a way to permute the DIMENSIONS of an array.
> Something that sounds like the function "permute()" in matlab.
>
> Given an array C of dimensions c x d x T , for instance, the command
>
> permute(C, [2 1 3])
>
?aperm
> would provide (in Matlab) an array very similar to C, but this time
> each
> one of the T matrices c x d has changed into its transposed.
> Any alternatives to the following (and primitive) 'for' cycle?
>
> *# (previously defined) phi=array with dimensions c(c,d,T)*
> *
> *
> *temp=array(0,dim=c(c,d,T))*
> * for(i in 1:T)*
> * {*
> * temp[,,i]=t(phi[,,i])*
> * }*
> * phi=temp*
> *
> *
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list