Re: [R] A one-liner to create a 3-dim array

From: Rolf Turner <>
Date: Tue 26 Jul 2005 - 04:24:01 EST

        B <- array(apply(A,1,function(x){x%o%x}),dim=c(nrow(A),dim(A)))


					Rolf Turner

Ravi Varadhan wrote:

> I would like to write a one-line R code to create a 3-dim array, B, of
> dimension (n,n,m) from a matrix, A, of dimension (m,n) such that the i-th
> element of the 3-dim array, B[, , i] is the outer product of the i-th row
> of A. mailing list PLEASE do read the posting guide! Received on Tue Jul 26 04:33:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:01 EST