On Mar 26, 2012, at 17:33 , David Winsemius wrote: > The usual approach to that problem is to use sapply: > > x <- list() > x <- sapply(1:10, function(z) x[[z]] <- 1:z )
Yikes! If that works, it is only by coincidence.... (The pre-assignment to x only serves the purpose of allowing the "[["-assignment inside the anonymous function, but the assignment is to a local copy which is deleted on exit, and the return value is the rhs of the assignment.) Please: x <- lapply(1:10, function(z) 1:z) or even x <- lapply(1:10, seq_len) -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.