I sometimes need to return multiple items from a loop. Is it possible to have the <<- operator work the same for mclapply as for lapply ?
> extra <- list() > squares <- mclapply(1:10, function(x){extra[[x]] <<- x; x^2;}) > extra list() > squares <- lapply(1:10, function(x){extra[[x]] <<- x; x^2;}) > extra [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 [[4]] [1] 4 [[5]] [1] 5 [[6]] [1] 6 [[7]] [1] 7 [[8]] [1] 8 [[9]] [1] 9 [[10]] [1] 10 My question is like that of http://tolstoy.newcastle.edu.au/R/e6/help/09/03/8329.html which is not answered. -------------------------------------- Dario Strbenac PhD Student University of Sydney Camperdown NSW 2050 Australia ______________________________________________ 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.