Skip to content

cast in reshape and reshape2

7 messages · Kaiyin Zhong, David Winsemius, Hadley Wickham

#
With reshape I can cast with multiple functions:
month variable       mean         sd
1      5    ozone  23.615385  22.224449
2      5  solar.r 181.296296 115.075499
3      5     wind  11.622581   3.531450
4      5     temp  65.548387   6.854870
5      6    ozone  29.444444  18.207904
6      6  solar.r 190.166667  92.882975
7      6     wind  10.266667   3.769234
8      6     temp  79.100000   6.598589
9      7    ozone  59.115385  31.635837
10     7  solar.r 216.483871  80.568344
11     7     wind   8.941935   3.035981
12     7     temp  83.903226   4.315513
13     8    ozone  59.961538  39.681210
14     8  solar.r 171.857143  76.834943
15     8     wind   8.793548   3.225930
16     8     temp  83.967742   6.585256
17     9    ozone  31.448276  24.141822
18     9  solar.r 167.433333  79.118280
19     9     wind  10.180000   3.461254
20     9     temp  76.900000   8.355671

Is there a way to do the same job with reshape2?
#
On Dec 23, 2011, at 2:58 PM, Kaiyin Zhong wrote:

            
Have you looked at the .summarise argument to dcast? That seems to  
deliver the same sort of results one gets with base::aggregate.
#
On Dec 23, 2011, at 5:58 PM, David Winsemius wrote:

            
Actually I see after looking at examples on the plyr-reshape- 
googlegroups group that it is not '.summarise' but rather 'summarise'.  
Unfortunately there are no links in the help pages that seem to  
describe its proper use ... a not uncommon failing for that package in  
my experience.

  
    
#
On Fri, Dec 23, 2011 at 1:58 PM, Kaiyin Zhong <kindlychung at gmail.com> wrote:
No, this is something that reshape2 does not support.

Hadley
#
?plyr::summarise seems pretty helpful to me.  If you can do better,
please submit a patch - they are very much appreciated.

Hadley
#
On Dec 23, 2011, at 9:23 PM, Hadley Wickham wrote:

            
My failure to find it stemmed from it not being mentioned in any way  
in package reshape2's help files, but maybe I was mistaken that it was  
meant to be used in that context?
2 days later
#
Well, it's not - which is why it's not documented in reshape2.

Hadley