Phil, That's very elegant, and certainly solves my problem. But in order to assign the value to v, I would do v=ifelse(r==1,v-1,v). Is it possible to do the assignment inside the conditional? That way I can save some running time of assigning v to itself. Thanks for your solution!
Sincerely, John -- View this message in context: http://r.789695.n4.nabble.com/element-wise-conditional-assignment-in-r-tp2951963p2952010.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.