Hi List, Trying to update a data.frame column within a foreach nested for loop
### trial data set.seed(666) xyz<-as.data.frame(cbind(x=rep(rpois(5000,10),2)+1, y=rep(rpois(5000,10),2)+1,z=round(runif(10000, min=-3, max=40),2))) xyz$mins<-rep(NA, nrow(xyz)) cl<-makeCluster(16) #adjust to your cluster number registerDoParallel(cl) counter=0 foreach(i=unique(xyz[,1]), .combine=data.frame, .verbose=T) %dopar% { for( j in unique(xyz[,2])) { xyz[xyz[,2] == j ,4]<-min(xyz[xyz[,2] == j ,2]) } } stopCluster(cl) This is obviously not working. Any hints? Thanx Herry ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.