Hi Sayan, This is exactly what I was looking for - it worked perfectly. Many thanks!! Also, thanks to everyone else for their suggestions. Pele -- View this message in context: http://r.789695.n4.nabble.com/For-loop-with-ifelse-help-tp2550547p2552388.html Sent from the R help mailing list archive at Nabble.com.