Hello all,
I'm working with a matrix that will have varying dimensions.  It will populate an array such that the number of matrix columns will determine the number of 3rd dimension levels of the array.  Rows will be the same for both.  For this example lets say the array will have 2 columns, but that's not fixed.

dim(arr)<-c(dim(mat)[1],2,dim(mat)[2])

 I wish to repeat each matrix column in the 3rd dimension of an array as follows in "desired appearance" below, but haven't quite got my generic array() function right.  I need the equivalent of byrow=TRUE when filling in the array.
thanks for all your help!


mat<-matrix(1:12,ncol=3)
mat
desired.arr<-array(NA,dim=c(dim(mat)[1],2,dim(mat)[2]))

#build array using generic code like this?
# need something like byrow=TRUE
array(rep(mat[1:dim(mat)[1],],each=dim(desired.arr)[2]),dim=dim(desired.arr))

# array needs to visually look as follows:
"desired appearance: "
array(c(rep(1:4,2),rep(5:8,2),rep(9:12,2)),dim=dim(desired.arr))


Michael Folkes

	[[alternative HTML version deleted]]

