Re: [R] Need to append vector to all levels of nested list WITHOUT a loop

2012-06-18 Thread Rui Barradas
Hello, Try (b <- list(list(m=4, v=5), list(m=6, v=7))) (m <- matrix(1:6, 2)) b2 <- lapply(seq_along(b), function(i){ b[[i]]$line <- m[i, ]; b[[i]]}) b2 Also, next time, post a data example, using dput(). Hope this helps, Rui Barradas Em 18-06-2012 14:54, Johannes Reichl escreveu:

[R] Need to append vector to all levels of nested list WITHOUT a loop

2012-06-18 Thread Johannes Reichl
Hi everyone, I have a list betaMoments with 2 levels, e.g. > beta1 = list( +m = 4, +v = 5 +) > beta2 = list( +m = 6, +v = 7 +) > > betaMoments = list() > betaMoments[[1]] = beta1 > betaMoments[[2]]