Skip to content
Prev 178202 / 398506 Next

deleting rows provisionally

On Fri, Apr 24, 2009 at 04:50:48AM -0700, onyourmark wrote:
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]