Re: [Rd] by should use match.fun

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 12 Jun 2005 - 19:21:59 GMT

On 6/12/05, Liaw, Andy <andy_liaw@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@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
> >
>
>
>
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachment...{{dropped}}



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Jun 13 05:25:05 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:09 GMT