Sarah,
This is simple if your data set is sorted by street (tested in R):
# toy example
dd <- data.frame(streets=sample(letters[1:10], 100, repl=TRUE),
munic=sample(LETTERS[1:3], 100, repl=TRUE))
dd <- dd[order(dd$streets),] # sort alpha by streets
dd2 <- dd[match(unique(dd$streets), dd$streets),]
HTH,
Alejandro
On 5/30/2007 at 4:19 PM, Sarah Henderson <sarah.henderson@ubc.ca> wrote:
> 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
|