Dear R-Users,

I have been using R for about 1 week and recently learned about the Aggregate function, and from reading online it seems like it is comparable to a SQL group by to perform summary functions.  I am looking to do a summary function, such as SUM/MIN, but instead of these basic functions, I would like to calculate the IRR.

Assuming I have a data set DS01:
FirstName         LastName         NCF      Date
A                      B                      -100                  1/1/2001
A                      B                      50                     2/1/2002
A                      B                      200                   3/1/2003
A                      C                      -500                  1/1/2001
A                      C                      50                     2/1/2002
A                      C                      70                     3/1/2003
A                      C                      50                     2/1/2004
A                      C                      70                     3/1/2005

And an IRR function which takes in a cash flow and dates as inputs: IRR(NCF,cfDate) and returns the IRR

I tried the following:
aggregate(DS01$NCF,by=list(DS01$ FirstName,DS01$ LastName),RR,cfDate=DS01$Date)

and I got the following error:
Error in aggregate.data.frame(as.data.frame(x), ...) :
  arguments must have same length

If anyone could shed some light on what may be causing this that would be great.
More importantly, is this the right way to do this (should I even be using the aggregate function)?

Any help would be greatly appreciated!
Thanks!





Please consider the environment before printing this e-mail.

	[[alternative HTML version deleted]]

