Re: [R] A file manipulation question

2004-03-04 Thread Marc Schwartz
--- Date: Wed, 03 Mar 2004 21:46:27 -0600 From: Marc Schwartz [EMAIL PROTECTED] To: Greg Blevins [EMAIL PROTECTED] Cc: R-Help [EMAIL PROTECTED] 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

[R] A file manipulation question

2004-03-03 Thread Greg Blevins
Hello R experts, The following problem outstrips my current programming knowledge. I have a dataframe with two fields that looks like the following: ID Contract 01 1 01 1 02 2 02 3 02 1 03 2 03 2 03 2 03 1 03 1 03 1 etc... I would

Re: [R] A file manipulation question

2004-03-03 Thread Andrew Robinson
How about something like ... (if your data frame is called the.data) summarized - as.data.frame(levels(the.data$ID)) names(summarized) - ID summarized$Contract - as.numeric(tapply(the.data$Contract, the.data$ID, max)) Andrew On Wednesday 03 March 2004 19:19, Greg Blevins wrote: Hello R

Re: [R] A file manipulation question

2004-03-03 Thread Marc Schwartz
On Wed, 2004-03-03 at 21:19, Greg Blevins wrote: Hello R experts, The following problem outstrips my current programming knowledge. I have a dataframe with two fields that looks like the following: ID Contract 01 1 01 1 02 2 02 3 02 1 03 2 03 2 03

RE: [R] A file manipulation question

2004-03-03 Thread Liaw, Andy
Say your data frame is `dat'. Try: tapply(dat$Contract, dat$ID, max) (The output is not a data frame, but that shouldn't be a problem...) HTH, Andy From: Greg Blevins Hello R experts, The following problem outstrips my current programming knowledge. I have a dataframe with two

Re: [R] A file manipulation question

2004-03-03 Thread Gabor Grothendieck
] Cc: R-Help [EMAIL PROTECTED] 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