Message-ID: <20090424123143.GD374@sqlserver>
Date: 2009-04-24T12:31:44Z
From: Hans Ekbrand
Subject: deleting rows provisionally
In-Reply-To: <23214891.post@talk.nabble.com>
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) <hans at 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090424/9538f7d1/attachment-0002.bin>