Re: [R] fun.aggregate=mean in reshape

From: jiho <jo.irisson_at_gmail.com>
Date: Tue, 12 Feb 2008 11:37:31 +0100

On 2008-February-12 , at 11:11 , Henrique Dallazuanna wrote:
> You can use aggregate:
>
> aggregate(data[,c("ozone", "solar.r", "wind", "temp")],
> list(month=data$month), mean)
>
> On 12/02/2008, [Ricardo Rodriguez] Your XEN ICT Team <webmaster_at_xen.net
> > wrote:
>> Hi all,
>>
>> We are facing a problem while introducing ourselves to Reshape
>> package
>> use. Melt seems to work fine, but cast fails when we use mean as
>> fun.aggregate. As you see here, length and sum work fine, but mean
>> throws this same error whatever dataset we use.
>>
>>> cast(aqm, month ~ variable, length)
>> month ozone solar.r wind temp
>> 1 5 26 27 31 31
>> 2 6 9 30 30 30
>> 3 7 26 31 31 31
>> 4 8 26 28 31 31
>> 5 9 29 30 30 30
>>> cast(aqm, month ~ variable, sum)
>> month ozone solar.r wind temp
>> 1 5 614 4895 360.3 2032
>> 2 6 265 5705 308.0 2373
>> 3 7 1537 6711 277.2 2601
>> 4 8 1559 4812 272.6 2603
>> 5 9 912 5023 305.4 2307
>>> cast(aqm, month ~ variable, mean)
>> Error in get(as.character(FUN), mode = "function", envir = envir) :
>> variable "fun" of mode "function" was not found
>>>
>>
>>
>> Our environment:
>>
>>> version
>> _
>> platform i386-apple-darwin8.10.1
>> arch i386
>> os darwin8.10.1
>> system i386, darwin8.10.1
>> status
>> major 2
>> minor 6.2
>> year 2008
>> month 02
>> day 08
>> svn rev 44383
>> language R
>> version.string R version 2.6.2 (2008-02-08)
>>
>>
>>> installed.packages()
>>
>> reshape "reshape"
>> "/Library/Frameworks/R.framework/Resources/library" "0.8.0"
>> NA NA
>>
>>
>> Please, could you help use to work out this issue? Thanks!

It probably won't help much, but may be interesting for diagnostic purposes: it works for me on the same environment except for R 2.6.1 instead of 2.6.2.
Have you tried specifying the argument name explicitely?

JiHO

---
http://jo.irisson.free.fr/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 12 Feb 2008 - 10:45:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Feb 2008 - 11:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive