Skip to content
Prev 208039 / 398502 Next

Create matrix with subset from unlist

OK, I've got this. The output prints what I want, but I'm not sure if 
there will be problems in further analysis because the main idea is to 
convert the data from list to matrix. I'm quite concerned with how I 
define xx2.

    xx <- unlist(x)   # Unlist  from lapply + read.table

    a <- seq(1,128,by=4) # creates sequence for increment in loop

    xx2 <- list() # Is this the correct definition?
for (z in 1:32){
 xx2[[z]] <- matrix(xx[c(a[z]:(a[z]+4))],2,2)
}

When I do,
    > mode(xx2)
    > [1] "list"

When I do,
    > xx3 <- xx2[[1]] + 5   # simple test
    > mode(xx3)
    > "numeric"


Am I doing this right?


Muhammad

----------
Muhammad Rahiz wrote: