Re: [R] extract and replace columns of matrices stored in a list

2009-09-05 Thread Henrique Dallazuanna
Try this: my.array <- replicate(10, data.frame(matrix(sample(9), 3)), simplify = FALSE) #2 lapply(my.array, replace, list = 3, values = newThirdColumn) The solution was for matrices, the above works with data.frames. On Thu, Sep 3, 2009 at 5:03 PM, Carlos Hernandez wrote: > > On Thu, Sep 3, 2

Re: [R] extract and replace columns of matrices stored in a list

2009-09-03 Thread Carlos Hernandez
On Thu, Sep 3, 2009 at 4:34 PM, Henrique Dallazuanna wrote: > Try this: > > #1 > lapply(my.array, '[', , 3) > > this works! thank you a lot! > #2 > newThirdColumn <- sample(3) > lapply(my.array, replace, list = 7:9, values = newThirdColumn) > > i did not understand this last line, so far i could

Re: [R] extract and replace columns of matrices stored in a list

2009-09-03 Thread Henrique Dallazuanna
Try this: #1 lapply(my.array, '[', , 3) #2 newThirdColumn <- sample(3) lapply(my.array, replace, list = 7:9, values = newThirdColumn) On Thu, Sep 3, 2009 at 11:16 AM, Carlos Hernandez wrote: > Dear All, > I created a list (of length Z) in the following way: > > my.array <- vector("list", Z) >

[R] extract and replace columns of matrices stored in a list

2009-09-03 Thread Carlos Hernandez
Dear All, I created a list (of length Z) in the following way: my.array <- vector("list", Z) then i assigned a matrix (of T rows by N columns) in each of the elements of the list my.array in the following way: my.array[[i]] <- matrix.data ##( matrix.data has dimensions TxN, and i repeated this