Thanks for the help, Perhaps I should elaborate a bit, I am working on bioinformatics project in which I am trying to run a forward selection algorithm for machine learning classification of two biological conditions. At each iteration I want to find the gene that in addition to those I have found already does the best classification.
It looks something like this: for (j in 1:5030) { tp <- 0; for (i in 1:5030) { if (!(i %in% idx)) { classifier<-naiveBayes(trn[,c(i,idx)], trn[,20118]) tbl <-table(predict(classifier, trn[,-20118]), trn[,20118]) success <- (tbl[[1]] +tbl[[4]])/(tbl[[1]] +tbl[[4]]+tbl[[2]]+tbl[[3]]) if (success > tp) { tp <- success ind <- i gene <- names(trn)[i] } } } idx <- c(idx,ind) res <- rbind(res, data.frame(Iteration=j,Success=tp*100,Gene=gene)) } I am no expert when it comes to programming so I am not sure how can I optimize my relatively primitive code in the best way... Thanks, Moriah -- View this message in context: http://r.789695.n4.nabble.com/Using-multicores-in-R-tp4651808p4652034.html Sent from the R help mailing list archive at Nabble.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.