Displaying 5 results from an estimated 5 matches for "integer__".
Did you mean:
integer_c
2017 May 23
2
Inconsistency in handling of numeric input with %d by sprintf
I initially thought this is "documented behaviour". ?sprintf says:
Numeric variables with __exactly integer__ values will be coerced to
integer. (emphasis mine).
Turns out this only works when the first value is numeric and not NA, as
shown by the following example:
> sprintf("%d", as.numeric(c(NA,1)))
Error in sprintf("%d", as.numeric(c(NA, 1))) :
invalid format '%d'; us...
2017 May 23
2
Inconsistency in handling of numeric input with %d by sprintf
...an edge case in how we printed ITime objects in data.table:
>
>
> On Tue, May 23, 2017 at 11:53 AM, Joris Meys <jorismeys at gmail.com> wrote:
>
>> I initially thought this is "documented behaviour". ?sprintf says:
>>
>> Numeric variables with __exactly integer__ values will be coerced to
>> integer. (emphasis mine).
>>
>> Turns out this only works when the first value is numeric and not NA, as
>> shown by the following example:
>>
>> > sprintf("%d", as.numeric(c(NA,1)))
>> Error in sprintf("%d&quo...
2017 May 23
0
Inconsistency in handling of numeric input with %d by sprintf
...ger when we use
%d. It's an edge case in how we printed ITime objects in data.table:
On Tue, May 23, 2017 at 11:53 AM, Joris Meys <jorismeys at gmail.com> wrote:
> I initially thought this is "documented behaviour". ?sprintf says:
>
> Numeric variables with __exactly integer__ values will be coerced to
> integer. (emphasis mine).
>
> Turns out this only works when the first value is numeric and not NA, as
> shown by the following example:
>
> > sprintf("%d", as.numeric(c(NA,1)))
> Error in sprintf("%d", as.numeric(c(NA, 1))) :...
2017 May 23
0
Inconsistency in handling of numeric input with %d by sprintf
...ed ITime objects in data.table:
>>
>>
>> On Tue, May 23, 2017 at 11:53 AM, Joris Meys <jorismeys at gmail.com> wrote:
>>
>>> I initially thought this is "documented behaviour". ?sprintf says:
>>>
>>> Numeric variables with __exactly integer__ values will be coerced to
>>> integer. (emphasis mine).
>>>
>>> Turns out this only works when the first value is numeric and not NA, as
>>> shown by the following example:
>>>
>>> > sprintf("%d", as.numeric(c(NA,1)))
>>> E...
2017 May 19
2
Inconsistency in handling of numeric input with %d by sprintf
Consider
#as.numeric for emphasis
sprintf('%d', as.numeric(1))
# [1] "1"
vs.
sprintf('%d', NA_real_)
> Error in sprintf("%d", NA_real_) :
invalid format '%d'; use format %f, %e, %g or %a for numeric object
>
I understand the error is correct, but if it works for other numeric input,
why doesn't R just coerce NA_real_ to NA_integer_?