Re: [R] Question on list objects

2011-01-08 Thread Gabor Grothendieck
On Sat, Jan 8, 2011 at 6:26 AM, Ron Michael wrote: > Hi, I have 2 questions on list object: > > 1. Suppose I have a matrix like: > dat <- matrix(1:9,3) > > Now I want to replicate this entire matrix 3 times and put entire result in a > list object. Means, if "res" is the resulting list then I sho

Re: [R] Question on list objects

2011-01-08 Thread Joshua Wiley
Hi Ron, Here you go. Cheers, Josh dat <- matrix(1:9,3) ldat <- list(dat, dat, dat) ldat[[1]] == dat ## Or lapply(1:3, function(x) dat) ## which is similar in spirit to output <- vector("list", 3) for(i in 1:3) { output[[i]] <- dat } list1 <- list2 <- vector("list", length=2) for(i in 1:2)

Re: [R] Question on list objects

2011-01-08 Thread Charles C. Berry
On Sat, 8 Jan 2011, Ron Michael wrote: Hi, I have 2 questions on list object: ? 1. Suppose I have a matrix like: dat <- matrix(1:9,3) ? Now I want to replicate this entire matrix 3 times and put entire result in a list object. Means, if "res" is the resulting list then I should have: ? res[[1]]

[R] Question on list objects

2011-01-08 Thread Ron Michael
Hi, I have 2 questions on list object:   1. Suppose I have a matrix like: dat <- matrix(1:9,3)   Now I want to replicate this entire matrix 3 times and put entire result in a list object. Means, if "res" is the resulting list then I should have:   res[[1]]=dat, res[[2]]=dat, res[[3]]=dat   How can