Re: [R] Assignment Operator in mclapply

2013-02-25 Thread Jeff Newmiller
Why do you equate using <<- with returning multiple items from a loop? There are valid reasons to use <<-, but the people who want to use it practically never have them. Just return a list of the items you want to return from within the function. squares <- mclapply(1:10, function(x){result <-

[R] Assignment Operator in mclapply

2013-02-25 Thread Dario Strbenac
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