s-news
[Top] [All Lists]

Re: Duplicate and Unique Data Frame Question

To: "'Overstreet, Jason'" <joverstreet@hotwater.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Duplicate and Unique Data Frame Question
From: "Alan Hochberg" <alan.hochberg@prosanos.com>
Date: Sat, 8 Sep 2007 16:23:42 -0400
In-reply-to: <1D345764276D6B45AEFADB0B8172FCEF02C19182@wpcmail.hotwater.aosmith.org>
Thread-index: Acfxm+lO8vRvHRo5Qa6trpAWVkNFAwAuUegg

Here is one of many possible ways to create separate data frames, based on whether the entry in a column appears more than once or not.  This one uses table()to count how often the items in x appear:

 

> tbl <- table(x)

> is.dupe <- tbl[x]>1

> dupeRows <- xy[is.dupe,]

> uniqueRows <- xy[not(is.dupe),]

> dupeRows

  x y

1 a 1

2 a 2

3 b 3

4 b 4

5 c 5

6 c 6

7 c 7

> uniqueRows

   x  y

 8 d  8

 9 e  9

10 f 10

> 

 

Hope this helps,

 

Alan

 

Alan Hochberg

VP, Research

 

ProSanos Corporation

225 Market St. Ste. 502,

Harrisburg, PA 17101

Tel 717-635-2124 * Fax 717-635-2575

 

<Prev in Thread] Current Thread [Next in Thread>