Displaying 1 result from an estimated 1 matches for "2x5x5".
Did you mean:
2x4x5
2006 Oct 24
3
Help with understanding [[]] [] array, list, matrix referencing
...matrices, lists, and objects using [[]] and []. I have read the
R guides and several tutorials but I am not the fastest kid on the block
so I am still having difficulty understanding this. For examples the
following code produces a 5 element list of 2X5 random numbers that I
then convert to a 2X5X5 matrix.
cov<-matrix(c(.4,-.1,-.1,.3),nrow=2,ncol=2)
rnds<-NULL;
for (i in 1:5){
t1<-rnorm(5,cov)
t2<-rnorm(5,cov)
t3<-rbind(t1,t2)
rnds[i]<-list(t3)
}
rnds.matrix<-array(unlist(rnds),dim=c(2,5,5));
To access the matrix rnds.matrix I use rnds.matrix[x,y,z]. This I
unders...