suppose you save your data as in the email to a file b.txt -- i ignore
niceties of delimiter choice

there are many ways of doing it, but here is one possibility

> bb = read.table("b.txt", h=TRUE, colClasses=c("character", "numeric",
"numeric", "numeric"))
> bbs = split(bb, bb[,1])
> t(sapply(bbs, function(x) x[which.min(x$pvalue),]))
      GeneSymbol A  B  pvalue
AB    "AB"       4  55 0.2
ABC1  "ABC1"     12 44 0.01
ABCD1 "ABCD1"    9  18 1e-04

it does what you ask, but the solution you gave below doesn't seem right
(picked wrong values of A and B for correct ABC1 candidate?)

On Fri, May 28, 2010 at 1:27 PM, mervi.alanne@wri.fi <mervi.alanne@wri.fi>wrote:

> Dear all,
>
> I'm a novice with R and could use some help. How could I find repeated
> observations based on one column and select the one to keep based on
> another column?
>
> In more detail, this is the thing I want to achieve:
> -data.frame has 4 columns GeneSymbol, A, B, pvalue
> -data in column GeneSymbol may be repeated 1-6 times
> -data also contains unique observations
> -Of the repeated obs, keep the obs which has the lowest pvalue
> -Do not discard data from cols A and B
>
> Example input data:
> GeneSymbol A B pvalue
> ABC1 12 44 0.01
> ABC1 2 32 0.05
> AB 4 55 0.2
> ABCD1 15 25 0.005
> ABCD1 11 27 0.002
> ABCD1 9 18 0.0001
>
> I'd like the output to look like this:
> GeneSymbol A B pvalue
> ABC1 2 32 0.01
> AB 4 55 0.2
> ABCD1 9 18 0.0001
>
> Any suggestions?
>
> -Mervi
> Wihuri Research Institute
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

