[Rd] Re: [R] abs() on data frames?!
Prof Brian D Ripley
ripley@stats.ox.ac.uk
Tue, 26 Feb 2002 21:23:45 +0000 (GMT)
Moved to R-devel, as this will get very technical!
On Tue, 26 Feb 2002, Henrik Bengtsson wrote:
> I might be wrong, but didn't the following work before R v1.4.x?
>
> R --vanilla
> > df <- data.frame(-10:10)
> > abs(df)
> Error in abs(df) : non-numeric argument to function
>
> I have tried this on both Rv1.4.1 on WinMe and Rv1.4.0 on Solaris 8. I
> regexp searched bugs.r-project.org on "abs" but I found nothing about this.
> I can't see why abs(df) shouldn't work when sqrt(df), log(df) etc works.
Both log and abs should be members of the group generic Math, and
Math.data.frame exists. In R sqrt is dispatched on that group, although I
don't see it documented as part of it,
But it looks like abs is being handled by the complex arithmetic section of
the code, as if it were Mod.
I do recall discussions of this long ago, but doubt if this has been
changed recently. Indeed, the names.c file has
/* KH(1999/09/12)-> complex: {"abs", do_math1, 0, 1, 1, PP_FUNCALL}, */
I'll fix it in R-devel.
--
Brian D. Ripley, ripley@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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._