Hi Adrienne,

I guess apply should be better than for loop. 

Code like this:

event.gen2 = function(genmat,use1,use2,num,ortho_obs_used){ 

      onerow.gen <- function(one.row, use1....){
              one.row[num] <- ifelse(...}
      genmat[,num] <- NA ##Add one row with NA values
      apply(genmat[-1,],1,onerow.gen,use1=...)}

And R looks TRUE as 1 and FALSE as 0, we may take advantage of it.

Regards,

Wu

-----
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Running-something-without-a-loop-when-the-result-from-the-previous-iteration-is-require-for-the-currn-tp2321526p2321688.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.

Reply via email to