[R] Merge partially duplicated rows

David Winsemius dwinsemius at comcast.net
Tue Aug 4 01:12:28 CEST 2009


On Aug 3, 2009, at 9:24 AM, Rnewbie wrote:

>
> Dear all,
>
> I have a dataset, and I wanted to merge the rows with duplicated IDs  
> by
> calculating the means or medians from the duplicate rows. I tried  
> using the
> command duplicated(x), but it only tells where the duplicated rows  
> are.

You might want to look at the ave function. It will calculate a  
function within IDs and you can assign that as another row in the  
datafrme before you exclude the duplicates.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list