[R] Is k equivalent to k:k ?

Marcus Davy MDavy at hortresearch.co.nz
Sun Dec 12 21:13:03 CET 2004


Havent seen anything on R-devel yet on this topic, but if the elseif statement on line 43 of seq.default was

  else if (length.out == 0) 
    double(0)

instead of 

  else if (length.out == 0) 
    numeric(0)

then that *might* satisfy Richard A. O'Keefe's comment for length=0:n cases

 >> storage.mode(seq(length=0))
    RichOK>     [1] "integer"
 >> storage.mode(seq(length=1))
    RichOK>     [1] "double"


marcus


>>> Martin Maechler <maechler at stat.math.ethz.ch> 10/12/2004 9:34:11 PM >>>
I'm diverting to R-devel, where this is really more
appropriate.  Here (R-help) only a shorter version:

>>>>> "RichOK" == Richard A O'Keefe <ok at cs.otago.ac.nz>
>>>>>     on Fri, 10 Dec 2004 14:37:16 +1300 (NZDT) writes:

    RichOK> In this discussion of seq(), can anyone explain to
    RichOK> me _why_ seq(to=n) and seq(length=3) have different
    RichOK> types?  

well, the explantion isn't hard:  look at  seq.default  :-)

    RichOK> In fact, it's worse than that (R2.0.1):

    >> storage.mode(seq(length=0))
    RichOK>     [1] "integer"
    >> storage.mode(seq(length=1))
    RichOK>     [1] "double"

  { str(.) is shorter than  storage.mode(.) }

    RichOK> If you want to pass seq(length=n) to a .C or
    RichOK> .Fortran call, it's not helpful that you can't tell
    RichOK> what the type is until you know n!  It would be nice
    RichOK> if seq(length=n) always returned the same type.  I
    RichOK> use seq(length=n) often instead of 1:n because I'd
    RichOK> like my code to work when n == 0; it would make life
    RichOK> simpler if seq(length=n) and 1:n were the same type.

now if that really makes your *life* simpler, what does that
tell us about your life  ;-) :-)

For more on this, see the "R-devel" list to which this has been diverted.

Martin Maechler, ETH Zurich

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________________

The contents of this e-mail are privileged and/or confidenti...{{dropped}}




More information about the R-help mailing list