[Rd] by should use match.fun
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Jun 12 21:21:59 CEST 2005
On 6/12/05, Liaw, Andy <andy_liaw at merck.com> wrote:
> I don't get the point. ?by says:
The point is that all other functions of this sort including apply, sapply,
tapply, lapply work like that so 'by' ought to as well.
Here is the example (changed to use iris) where I noticed it. Suppose we
want to create a list of rows:
by(iris, row.names(iris), "(")
In every other similar function this would have worked but here we must do:
by(iris, row.names(iris), match.fun("("))
>
> FUN a function to be applied to data frame subsets of data.
>
> It doesn't say FUN can be a character, and by(iris, iris$Species, summary)
> works as expected.
>
> Andy
>
> > From: Gabor Grothendieck
> >
> > I noticed that, unlike similar functions, 'by' does not use
> > match.fun, e.g.
> >
> > > by(iris, iris$Species, "summary")
> > Error in FUN(X[[1]], ...) : couldn't find function "FUN"
> >
> > The 'by' code should have an initial line of:
> >
> > FUN <- match.fun(FUN)
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
> >
>
>
>
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachment...{{dropped}}
More information about the R-devel
mailing list