Re: [R] List of arrays - problem with dimensions

2012-10-30 Thread Loukia Spineli
Imagine a list of two arrays. The first array is like a vector that contains ten 2x2 matrices. The second array contains two vectors of 2x2 matrices of length five and three, respectively. I run the code and it gives me what I want for the first array. However, it disappoints me for the second arra

Re: [R] List of arrays - problem with dimensions

2012-10-28 Thread Loukia Spineli
x = c( 4 , 4 , 0 ) y = c( 1 , 0 , 2 ) t = c( 1 , 2, 2 ) r <- as.vector(table(t)) Nx <- vector("list",length(unique(t))) Ny <- vector("list",length(unique(t))) n <- vector("list",length(unique(t))) for(i in 1:length(unique(t))){ Nx[[i]] <- array(0,dim=c(1,r[i],1))+x[t==i]+1 Ny[[i]]

Re: [R] List of arrays - problem with dimensions

2012-10-28 Thread Richard M. Heiberger
This time the code works, except for the spurious "}" at the end. I still don't know what the goal is. Please help yourself and us by putting spaces around assignment arrows a <- b instead of the hard-to-read a<-b and putting spaces after "," ## Let a <- 12 ## Does a<-3 ## mean a <- 3 ## or a< -

Re: [R] List of arrays - problem with dimensions

2012-10-28 Thread Loukia Spineli
I am "refreshing" the code for the problem x = c( 4 , 4 , 0 ) y = c( 1 , 0 , 2 ) t = c( 1 , 2, 2 ) r<-as.vector(table(t)) Nx<-vector("list",length(unique(t))) Ny<-vector("list",length(unique(t))) n<-vector("list",length(unique(t))) for(i in 1:length(unique(t))){ Nx[[i]]<-array(0,d

Re: [R] List of arrays - problem with dimensions

2012-10-28 Thread Richard M. Heiberger
Your example is hard to understand because it includes multiple copies of the number "1". Let me do something with different values and see if it gets what you are after. Your code as posted can't work because the variable n is not defined. result <- list(a=array(1:48, dim=c(2,2,3,4)),

[R] List of arrays - problem with dimensions

2012-10-28 Thread Loukia Spineli
Dear all, I want to obtain the following result [[1]] , , 1, 1 [,1] [,2] [1,]11 [2,]11 , , 2, 1 [,1] [,2] [1,]11 [2,]11 , , 9, 1 [,1] [,2] [1,]11 [2,]11 , , 10, 1 [,1] [,2] [1,]11 [2,]11