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

From: Peter Dalgaard <>
Date: Wed, 13 Feb 2008 07:41:23 +0100

Charilaos Skiadas wrote:
> On Feb 12, 2008, at 1:31 PM, [Ricardo Rodriguez] Your XEN ICT Team
> wrote:
>> Sundar Dorai-Raj wrote:
>> Could it we advisable that cast, melt or whatever function we deal
>> with
>> throws an more informative error message when this kind of conflicts
>> occur? I am guessing this is a pretty frequent situation, so if it is
>> not done there must be a number of good reasons!
>> Just my two cents!
> I think this is appropriate here:
> > library(fortunes)
> > fortune("dog")
> Firstly, don't call your matrix 'matrix'. Would you call your dog
> 'dog'? Anyway, it might clash
> with the function 'matrix'.
> -- Barry Rowlingson
> R-help (October 2004)
> in other words, it is advisable that you don't call anything "mean".
> The error seems to be almost as clear as it could in this case:
> Error in get(as.character(FUN), mode = "function", envir = envir) :
> variable "fun" of mode "function" was not found
> It tells you that a call to get was attempted looking for a variable
> of mode "function", and such a variable was not found. The problem is
> of course that the call tells you the variable is named "fun", while
> you expected it to be named "mean". But it alerts to the fact that
> the program was expecting a function in a place where it was given
> something else, and there is only one place where you provide it a
> function.
This does however sound like the author missed the opportunity to use (see, e.g. how it is used inside lapply()). This is exactly designed to avoid picking up non-function objects. I haven't actually read the code, though, so there could be reasons.

> Also, the fact that the call works fine without the fun.aggregate, or
> with a different fun.aggregate, prompts to the problem being the word
> "mean".
> Then typing "mean" followed by return would show you, instead of the
> function body for the function mean, something quite different.
> I have to admit that a cursory look at the code for cast does not
> immediately tell me where "fun" shows up, however, so I am slightly
> mystified by the error.
>> Thanks for your help,
>> Ricardo
>> --
>> Ricardo Rodríguez
>> Your XEN ICT Team
> Haris Skiadas
> Department of Mathematics and Computer Science
> Hanover College
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.

   O__  ---- Peter Dalgaard             Řster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 13 Feb 2008 - 06:49:24 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 Wed 13 Feb 2008 - 07:30:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive