You could try aggregate:

If we call your data frame df:

aggregate(df[2], by=df[1], FUN=min)

will get you what you asked for (if not necessarily what you need ;-)
)

Switching the columns around is easy enough if you need to; proceeding
stepwise:
df.new<-aggregate(df[2], by=df[1], FUN=min)
df.new[,c(2,1)]

As to how I found aggregate: watching R-help daily for years
occasionally pops up fundamental gems like aggregate...

 Steve Ellison
LGC

>>> Jonathan <jonsle...@gmail.com> 08/02/2010 16:39:11 >>>
What I'd like is to return a dataframe cut down to have only unique
entires in V1.  V2 should contain a vector, for each V1, that is the
minimum of all the possible choices from the set of redundant V1's.

Example output:

      V1     V2
1     a        2
2     b        9
3     c        4



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to