Dear all,



I am having trouble creating a "jagged array" in R.  I have found no commentary on how to do it in the help files, but maybe I am misunderstanding the purpose of some of the array functions (e.g. tapply).



I am using a longitudinal dataset where each individual has a different number of time points (observations).  I need to create correlation structures for each individual which are necessarily different lengths.  Currently I am using for loops in an attempt to do so.  The closest I can get is with the following code (n=3) where I create matrices of the same dimensions with NA's for timepoints not used.  Perhaps there is simply a way to drop these NA's?



I would appreciate any thoughts on how to create a jagged array to store matrices of different dimensions or direction towards a help-file or package that will help me out.



Thanks in advance!





 n<-3     #sample size
tim<-c(10,12,5)   #number of observations per individual
 tim.pts<-12        #number of possible observations
 struc<-array(NA,dim=c(tim.pts,tim.pts,n))


for(i in 1:n){

   for(k in 1:tim[i]){
   for(j in k:tim[i]){
     struc[k,j,i]<-  (exp(-(j-k)))
    struc[j,k,i]=struc[k,j,i]
    }
  }


            }

	[[alternative HTML version deleted]]

