On Fri, Apr 24, 2009 at 04:50:48AM -0700, onyourmark wrote: > > Hi. Thanks very much for the reply and the good suggestion. It works well. > But I don't get why the for loop is not deleting anything or making any > assignments? Or I should say, doesn't answer3[-i,] delete entries from > answer3 when the if condition is true?
Your for loop was: for(i in 1:1537){if(answer2[i,1]==answer2[i,2]){answer3[-i,]}} No, answer3[-i] does not remove item i from answer3, it returns an anonymous temporary object which is identical to (answer3 without item i). Since that object not saved, it is deleted when the loop enters the next iteration. To actually *modify* answer3 you can use: answer3 <- answer3[-i] -- Hans Ekbrand (http://sociologi.cjb.net) <h...@sociologi.cjb.net> Q. What is that strange attachment in this mail? A. My digital signature, see www.gnupg.org for info on how you could use it to ensure that this mail is from me and has not been altered on the way to you.
signature.asc
Description: Digital signature
______________________________________________ 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.