Skip to content
Prev 273076 / 398506 Next

error using ddply to generate means

Hi:

Here's the problem:
'data.frame':   4 obs. of  3 variables:
 $ sector    :'data.frame':     4 obs. of  1 variable:
  ..$ gics_sector_name: chr  "Financials" "Financials" "Materials" "Materials"
 $ bebitpcchg: num  -0.567 0.996 NA -42.759
 $ ticker    : chr  "UBSN VX Equity" "LLOY LN Equity" "AI FP Equity"
"AKE FP Equity"

Notice that fun3$sector is a data frame, not a variable. By leaving
fun3 intact, the summary is gotten with

ddply(fun3, .(sector$gics_sector_name), summarise,
avgbebitchg=mean(bebitpcchg,na.rm=TRUE))
  sector$gics_sector_name avgbebitchg
1              Financials   0.2142787
2               Materials -42.7587479

You might consider reframing fun3, pardon the pun.

HTH,
Dennis
On Sat, Oct 1, 2011 at 7:58 AM, Aidan Corcoran
<aidan.corcoran11 at gmail.com> wrote: