[R] Is k equivalent to k:k ?

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri Dec 10 02:37:16 CET 2004

In this discussion of seq(), can anyone explain to me _why_
seq(to=n) and seq(length=3) have different types?
In fact, it's worse than that (R2.0.1):

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

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

Can anyone explain to me why the arguments of seq.default are
"from", "to", "by", "length.out", "along.with"
                           ^^^^         ^^^^^
when the help page for seq documents them as
"from", "to", "by", "length", and "along"?

More information about the R-help mailing list