[R] Is there "orphan code" in seq.default?

David Winsemius dwinsemius at comcast.net
Sat Aug 15 23:01:47 CEST 2015


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.

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list