Skip to content

round(numeric(0)) (PR#235)

3 messages · Kurt Hornik, Brian Ripley

#
Try
[1] NA
numeric(0)
numeric(0)

S has them all as numeric(0), and I think R is wrong.
This looks like a design error in the math2 group: it applies to 
signif too, and also to the complex cases, e.g.
[1] NA



--please do not edit the information below--

Version:
 platform = sparc-sun-solaris2.6
 arch = sparc
 os = solaris2.6
 system = sparc, solaris2.6
 status = 
 status.rev = 0
 major = 0
 minor = 64.2
 year = 1999
 month = July
 day = 3
 language = R

Search Path:
 .GlobalEnv, package:ts, Autoloads, package:base

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
In math2, we have

    if (na < 1 || nb < 1) {
        for (i = 0; i < n; i++)
            y[i] = NA_REAL;
    }

with

    na = LENGTH(sa);
    nb = LENGTH(sb);
    n = (na < nb) ? nb : na;

round(numeric(0)) really does round(numeric(0), 0) and hence we have na
= 0, n = nb = 1.  I think math2 is about right because you need that
sort of symmetry for recycling, but do_round() could know better.  Now

R> round(pi, 1:4)
[1] 3.1000 3.1400 3.1420 3.1416

is supposed to work so is it really clear what we want?  (if either arg
has length 0, does the result have length 0?  Should this be true for
any math2 type function?)

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 29 Jul 1999, Kurt Hornik wrote:

            
Yes, I think that is what Svr4 says is the correct behaviour: the recycling
rules have been changed to be consistent (JMC says somewhere in the Green 
book) and any zero-length vector immediately makes the result of zero
length.