Skip to content

seq.int does not return a sequence of integers sometimes

3 messages · Paul Johnson, Marc Schwartz, Duncan Murdoch

#
I have a script that goes wrong because I assumed that seq.int would
return integers.

Below please see it does not unless user is super cautious about
inserting "L" with inputs. I think seq.int should do coercion for me
before returning the sequence.
[1] "integer"
[1] TRUE
[1] "numeric"
[1] FALSE
[1] "numeric"
[1] FALSE
[1] "integer"
[1] TRUE


I think all of those should have same return value, if the function is
correctly named seq.int.
#
Paul,

?seq.int has the following:

under Details:

"seq.int is an internal generic which dispatches on methods for "seq" based on the class of the first supplied argument (before argument matching)."

and under Value:

"seq.int and the default method of seq for numeric arguments return a vector of type "integer" or "double": programmers should not rely on which."


So:
[1] FALSE
[1] TRUE

which would seem to explain the behavior that you are observing.

Regards,

Marc Schwartz
#
On 03/08/2016 4:12 PM, Paul Johnson wrote:
"int" means "internal", not "integer".  Sometimes you should read the 
documentation.

Duncan Murdoch