1

I'm running the example code for dplyr::summarize, and not getting the results I expect.

summarise(group_by(mtcars, cyl), 
          mean = mean(disp))
      mean
1 230.7219

ddply(mtcars, .(cyl), summarise,
       mean = mean(disp))
  cyl     mean
1   4 105.1364
2   6 183.3143
3   8 353.1000

What's going on here?

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
dplyr_0.1.2  
plyr_1.8 
Arun
  • 108,644
  • 21
  • 263
  • 366
Nan
  • 446
  • 4
  • 14
  • I'm also having similar issues. – dvdkamp Apr 11 '14 at 20:12
  • 5
    It's most likely that you loaded `dplyr` first and then `plyr` after and then ran the code. Both have names `summarise` and it's calling `plyr:::summarise` in your first case. Try running `dplyr:::summarise(.)` – Arun Apr 11 '14 at 20:27
  • @Arun- looks great! Want to make that the answer so I can select it? – Nan Apr 11 '14 at 20:36
  • 1
    Or load plyr first and dplyr second. – hadley Apr 11 '14 at 21:54
  • See also [**here**](http://stackoverflow.com/questions/22801153/ddply-error-in-n-function-should-not-be-called-directly). – Henrik Apr 12 '14 at 08:03

0 Answers0