s-news
[Top] [All Lists]

Re: A (probably) trivial question about first occurrence in unique()

To: "Sarah Henderson" <sarah.henderson@ubc.ca>, s-news@lists.biostat.wustl.edu
Subject: Re: A (probably) trivial question about first occurrence in unique()
From: "Greg Snow" <Greg.Snow@intermountainmail.org>
Date: Wed, 30 May 2007 15:28:49 -0600
In-reply-to: <7.0.1.0.2.20070530141341.0254bc50@ubc.ca>
Thread-index: AcejAJwKbq42veHvTcGocQLtiBU/zwAAMHiw
Thread-topic: [S] A (probably) trivial question about first occurrence in unique()
See ?duplicated

It returns a logical vector with F for the first occurance of each value
and T for the duplicates.  Invert that and use it to subscript the
vector of munincipalities and it should give you what you want.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow@intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: s-news-owner@lists.biostat.wustl.edu 
> [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of 
> Sarah Henderson
> Sent: Wednesday, May 30, 2007 3:20 PM
> To: s-news@lists.biostat.wustl.edu
> Subject: [S] A (probably) trivial question about first 
> occurrence in unique()
> 
> 
> Hello to all --
> 
> I have data for 300000 road segments reflecting approximately 
> 60000 unique street names.  I would like to create a new data 
> frame with the unique street names and their first-occurrence 
> municipalities (they are sorted North to South).  Of course 
> unique(STREETS) gives me the first part, but is there some 
> way to get the MUNIC of the first occurrence without writing a loop?
> 
> Many thanks,
> 
> Sarah
> 
> --------------------------------------------------------------------
> This message was distributed by 
> s-news@lists.biostat.wustl.edu.  To unsubscribe send e-mail 
> to s-news-request@lists.biostat.wustl.edu with the BODY of 
> the message:  unsubscribe s-news
> 


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