[R] A file manipulation question

Gabor Grothendieck ggrothendieck at myway.com
Thu Mar 4 06:12:09 CET 2004


You can ensure the name gets set appropriately like this:

> aggregate(list(Contract=df$Contract), list(ID=df$ID), max)
  ID Contract
1 01        1
2 02        3
3 03        2


---
Date:   Wed, 03 Mar 2004 21:46:27 -0600 
From:   Marc Schwartz <MSchwartz at medanalytics.com>
To:   Greg Blevins <gblevins at mn.rr.com> 
Cc:   R-Help <r-help at stat.math.ethz.ch> 
Subject:   Re: [R] A file manipulation question 

[...]

> aggregate(df$Contract, list(ID = df$ID), max)
ID x
1 01 1
2 02 3
3 03 2


See ?aggregate for more information. By default, aggregate() names the
function derived column as 'x'. You can of course rename it as you need.

HTH,

Marc Schwartz




More information about the R-help mailing list