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
>
|