[R] Conditional Weighted Average (ddply or any other function)

2013-03-01 Thread Punit Anand
Hello R community, I am computing weighted average statistic by using ddply function: My data set is: N1 T1 S1 I1 C1 FY-4 ROE11 EPS11 MKT11 N1 T1 S1 I1 C1 FY-3 ROE12 EPS12 MKT12 N1 T1 S1 I1 C1 FY-2 ROE13 EPS13 MKT13 N1 T1 S1 I1 C1 FY-1 ROE14 EPS14 MKT14 N1 T1 S1 I1 C1

Re: [R] Conditional Weighted Average (ddply or any other function)

2013-03-01 Thread Punit Anand
Hi John, The sample size is huge involving 10,000 + firms. I have put a representative sample using dput ( Name, ticker and country have been changed so that firms cannot be identified due to proprietary data set, also EPS is not required and removed from the dataset) structure(list(NAME = struct

Re: [R] Conditional Weighted Average (ddply or any other function)

2013-03-01 Thread Punit Anand
oops - it should be MKT, I have been playing with a number of data sets simultaneously. ddply (dataread , .(Sector, FISCALYEAR), summarise,WROE=wavg(ROE, MKT))) On Fri, Mar 1, 2013 at 2:23 PM, John Kane wrote: > Okay I got the data but you seem to have an undefined variable in wavg. > You write

Re: [R] Conditional Weighted Average (ddply or any other function)

2013-03-01 Thread Punit Anand
For Sectors the results are correct, but for some (Country, Industry, FISCALYEAR) combinations or (Country, FISCALYEAR) combinations the result don't match the spreadsheet (Excel) computation, so verifying from experts, whether I am using ddply correctly with the right intention? On Fri, Mar 1,

[R] Help Required in using cast (reshape package) function

2007-11-21 Thread Punit Anand
D + Period ~ variable) When I do that the data is casted as a pivot with a warning "Aggregation requires fun.aggregate: length used as default", and the casted data gives me the count of variables (as suggested by the warning ) Id Region Country Industry Period "a

Re: [R] Help Required in using cast (reshape package) function

2007-11-21 Thread Punit Anand
-Original Message- From: Punit Anand Sent: Wednesday, November 21, 2007 11:21 AM To: 'r-help@r-project.org' Subject: Help Required in using cast (reshape package) function Hello everyone, I am new to R. I have data in the form of excel pivot table format and I want to cast it into a fo