Thanks Rui, that was exactly what I was looking for! Have successfully implemented it and got rid of yet another loop! Cheers, Chris -- View this message in context: http://r.789695.n4.nabble.com/Dealing-with-NAs-in-C-tp4421377p4421532.html Sent from the R help mailing list archive at Nabble.com.