addmargins

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

addmargins

J. R. M. Hosking
 > 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?


 > R.version
          _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.1
year     2005
month    12
day      20
svn rev  36812
language R


J. R. M. Hosking

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: addmargins

Brian Ripley
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,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel