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

2005-07-25 Thread Huntsinger, Reid
I think this works: B <- aperm(rep(t(A),n)*rep(A,rep(n,n*m)), perm=c(1,3,2)) Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Monday, July 25, 2005 1:39 PM To: r-help@stat.math.ethz.ch Subject: [R] A one-liner

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

2005-07-25 Thread Rolf Turner
B <- array(apply(A,1,function(x){x%o%x}),dim=c(nrow(A),dim(A))) cheers, Rolf Turner [EMAIL PROTECTED] Ravi Varadhan wrote: > I would like to write a one-line R code to create

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

2005-07-25 Thread Ravi Varadhan
Hi, 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. Thanks for any help, Ravi. [[alternative HTML ve