On 08/15/2015 02:01 PM, David Winsemius wrote:> I was looking at the code in seq.default and saw code that I think would
throw an error if it were ever executed, although it will not because there is
first a test to see if one of its arguments is missing. Near the end of the
function body is this code:
>
> else if (missing(by)) {
> if (missing(to))
> to <- from + length.out - 1L
> if (missing(from))
> from <- to - length.out + 1L
> if (length.out > 2L)
> if (from == to)
> rep.int(from, length.out)
> else as.vector(c(from, from + seq_len(length.out -
> 2L) * by, to))
>
> Notice that the last call to `else` would be returning a value calculated
with 'by' which was already established as missing.
>
missing arguments can have default values
> f = function(by="sea") if (missing(by)) by
> f()
[1] "sea"
which is the case for seq.default
> args(seq.default)
function (from = 1, to = 1, by = ((to - from)/(length.out - 1)),
length.out = NULL, along.with = NULL, ...)
Martin Morgan
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793