[Rd] seq.int does not return a sequence of integers sometimes

Duncan Murdoch murdoch.duncan at gmail.com
Wed Aug 3 23:19:58 CEST 2016


On 03/08/2016 4:12 PM, Paul Johnson wrote:
> I have a script that goes wrong because I assumed that seq.int would
> return integers.

"int" means "internal", not "integer".  Sometimes you should read the 
documentation.

Duncan Murdoch

>
> 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.
>
>> xx <- seq.int(1,10)
>> class(xx)
> [1] "integer"
>> is.integer(xx)
> [1] TRUE
>> xx <- seq.int(1,10, 2)
>> class(xx)
> [1] "numeric"
>> is.integer(xx)
> [1] FALSE
>> xx <- seq.int(1,10, 2L)
>> class(xx)
> [1] "numeric"
>> is.integer(xx)
> [1] FALSE
>> xx <- seq.int(1L, 10L, 2L)
>> class(xx)
> [1] "integer"
>> is.integer(xx)
> [1] TRUE
>
>
> I think all of those should have same return value, if the function is
> correctly named seq.int.
>



More information about the R-devel mailing list