Re: [R] A Calculation on list object

2011-06-06 Thread Gabor Grothendieck
On Mon, Jun 6, 2011 at 6:10 PM, Ron Michael wrote: > Hello, I am into some calculation on a list object, therefore requesting the > peers if there is any short cut way to so the same calculation. > > Let say I have following list object: > >> List <- vector('list', length = 3) >> set.seed(1) >> L

Re: [R] A Calculation on list object

2011-06-06 Thread Joshua Wiley
Hi Ron, Seems like there might be a really elegant way, but I would use lapply(). For instance: lapply(seq_along(List), function(x) List[[x]] + Vector[x]) If you do this regularly and want something that reads more intuitively, consider defining an operator that does this. %+% is undefined (at

[R] A Calculation on list object

2011-06-06 Thread Ron Michael
Hello, I am into some calculation on a list object, therefore requesting the peers if there is any short cut way to so the same calculation. Let say I have following list object: > List <- vector('list', length = 3) > set.seed(1) > List[[1]] <- rnorm(5) > List[[2]] <- rnorm(2) > List[[3]] <- rno