[Rd] by should use match.fun (PR#7936)

ggrothendieck@gmail.com ggrothendieck at gmail.com
Tue Jun 14 14:08:06 CEST 2005

Full_Name: G. Grothendieck
Version: R version 2.1.0, 2005-06-10
OS: Windows XP
Submission from: (NULL) (

This is an inconsistency between by and similar functions.  
The 'by' function should have an initial line of:

FUN <- match.fun(FUN)

All other similar functions including apply, sapply,
tapply, lapply work like that so 'by' ought to as well.  

Here is an example using the 'iris' data set.  Suppose we 
wish to create a list of rows:

by(iris, row.names(iris), "(")

In every other similar function "(" would have been interpreted
as the intended function but here we get an error that it cannot
find "(".  Although such an error is not inconsistent with the
documentation it would seem to violate the consistency of the
R base functions mentioned.

There was a discussion of this on r-devel in this thread:


More information about the R-devel mailing list