From ripley at stats.ox.ac.uk  Tue Feb 14 16:19:34 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 14 Feb 2006 15:19:34 +0000 (GMT)
Subject: [Rd] addmargins
In-Reply-To: <dsrftd$9t$1@sea.gmane.org>
References: <dsrftd$9t$1@sea.gmane.org>
Message-ID: <Pine.LNX.4.64.0602140812150.27036@gannet.stats.ox.ac.uk>

On Mon, 13 Feb 2006, J. Hosking wrote:

> > addmargins(UCBAdmissions, FUN = list(Total=sum))
>
> works with no problems, but consider:
>
> > myFUN <- list(Total=sum)
> > addmargins(UCBAdmissions, FUN = myFUN)
> Error in "names<-.default"(`*tmp*`, value = "") :
>         names() applied to a non-vector
>
> Is this a bug?

I believe so.  addmargins contains

FUN <- eval(add.names(substitute(FUN)))

and that only makes sense if FUN is a call and not a symbol.  I've made 
the appropriate change to R-devel.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] addmargins
Prof Brian Ripley