[18686] in s-news-athena
Re: [S] identical obervations
daemon@ATHENA.MIT.EDU (Z. Todd Taylor)
Wed Jul 21 12:14:29 1999
Date: Wed, 21 Jul 1999 09:06:30 -0700 (PDT)
From: "Z. Todd Taylor" <Todd.Taylor@pnl.gov>
To: s-news@wubios.wustl.edu
Cc: todd.taylor@pnl.gov
Message-Id: <199907211606.JAA29715@aggie.pnl.gov>
John Thaden <jjthaden@flash.net> wrote (in response to
"Man S. Kwok" <mankwok@phoenix.princeton.edu>):
>
> : I have a data set of 6 varaibles and 2000 observations. I need to remove
> : repeated observations. Is there a quick way to locate exactly indentical
> : observations in S, without resorting to looping? Thanks in advance.
>
> > D <- D[!(duplicated(D$x1) & duplicated(D$x2) & duplicated(D$x3)
> + & duplicated(D$x4) & duplicated(D$x5) & duplicated(D$x6)), ]
>
Nope.
Try that on this matrix:
x1 x2 x3
-- -- --
1 2 3
2 3 4
1 2 4
Your approach will inappropriately eliminate the last row.
I always do something like:
all.in.one <- apply(D, 1, paste, collapse=",")
D.nodup <- D[ !duplicated(all.in.one), ]
--Todd
--
Z. Todd Taylor
Pacific Northwest National Laboratory
Todd.Taylor@pnl.gov
Why do 'slim chance' and 'fat chance' mean the same thing?
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news