Displaying 20 results from an estimated 800 matches similar to: "Translations and snprintf on Windows"
2017 May 23
2
Inconsistency in handling of numeric input with %d by sprintf
https://github.com/Rdatatable/data.table/issues/2171
The fix was easy, it's just surprising to see the behavior change almost on
a whim. Just wanted to point it out in case this is unknown behavior, but
Evan seems to have found this as well.
On Tue, May 23, 2017 at 12:00 PM, Michael Chirico <michaelchirico4 at gmail.com
> wrote:
> Astute observation. And of course we should be
2019 May 27
2
rbind has confusing result for custom sub-class (possible bug?)
Yes, thanks for following up on thread here. And thanks again for clearing
things up, your email was a finger snap of clarity on the whole issue.
I'll add that actually it was data.table's code at fault on the storage
conversion -- note that if you use an arbitrary sub-class 'foo' with no
methods defined, it'll stay integer.
That's because [<- calls as.Date and then
2019 May 26
2
rbind has confusing result for custom sub-class (possible bug?)
On Sun, May 26, 2019 at 4:06 AM Michael Chirico
<michaelchirico4 at gmail.com> wrote:
>
> Have finally managed to come up with a fix after checking out sys.calls()
> from within the as.Date.IDate debugger, which shows something like:
>
> [[1]] rbind(DF, DF)
> [[2]] rbind(deparse.level, ...)
> [[3]] `[<-`(`*tmp*`, ri, value = 18042L)
> [[4]] `[<-.Date`(`*tmp*`,
2019 May 26
2
rbind has confusing result for custom sub-class (possible bug?)
Debugging this issue:
https://github.com/Rdatatable/data.table/issues/2008
We have custom class 'IDate' which inherits from 'Date' (it just forces
integer storage for efficiency, hence, I).
The concatenation done by rbind, however, breaks this and returns a double:
library(data.table)
DF = data.frame(date = as.IDate(Sys.Date()))
storage.mode(rbind(DF, DF)$date)
# [1]
2019 Jun 02
1
rbind has confusing result for custom sub-class (possible bug?)
I thought it would be good to summarize my thoughts, since I made a
few hypotheses that turned out to be false.
This isn't a bug in base R, in either rbind() or `[<-.Date`.
To summarize the root cause:
base::rbind.data.frame() calls `[<-` for each column of the
data.frame, and there is no `[<-.IDate` method to ensure the
replacement value is converted to integer. And, in fact,
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
2019 Jan 11
2
strtoi output of empty string inconsistent across platforms
Identified as root cause of a bug in data.table:
https://github.com/Rdatatable/data.table/issues/3267
On my machine, strtoi("", base = 2L) produces NA_integer_ (which seems
consistent with ?strtoi: "Values which cannot be interpreted as integers or
would overflow are returned as NA_integer_").
But on all the other machines I've seen, 0L is returned. This seems to be
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_?
2019 Jan 11
2
strtoi output of empty string inconsistent across platforms
>>>>> Martin Maechler
>>>>> on Fri, 11 Jan 2019 09:44:14 +0100 writes:
>>>>> Michael Chirico
>>>>> on Fri, 11 Jan 2019 14:36:17 +0800 writes:
>> Identified as root cause of a bug in data.table:
>> https://github.com/Rdatatable/data.table/issues/3267
>> On my machine, strtoi("", base =
2018 Feb 27
2
scale.default gives an incorrect error message when is.numeric() fails on a sparse row matrix (dgeMatrix)
I am attempting to use the lars package with a sparse input feature matrix,
but the following fails:
library(Matrix)
library(lars)
data(diabetes)
attach(diabetes)
x = as(as.matrix(as.data.frame(x)), 'dgCMatrix')
lars(x, y, intercept = FALSE)
Error in scale.default(x, FALSE, normx) :
>
> length of 'scale' must equal the number of columns of 'x'
>
>
More
2017 May 23
0
Inconsistency in handling of numeric input with %d by sprintf
Yes, what Joris posts about is exactly what I noted in my March 9th post to
R-devel. The behaviour is sort of documented, but not in the clearest
manner (in my opinion). Like I say, my ultimate conclusion was that the
silent coercion of numerics to integers by sprintf() was a handy
convenience, but not one that should be relied about to always work
predictably.
On Tue, May 23, 2017 at 10:02 AM,
2018 Mar 05
1
model.frame strips class as promised, but fails to strip OBJECT in C
Full thread here:
https://github.com/tidyverse/broom/issues/287
Reproducible example:
is.object(freeny$y)
# [1] TRUE
attr(freeny$y, 'class')
# [1] "ts"
class(freeny$y)
# [1] "ts"
# ts attribute wiped by model.frame
class(model.frame(y ~ ., data = freeny)$y)
# [1] "numeric"
attr(model.frame(y ~ ., data = freeny)$y, 'class')
# NULL
# but still:
2020 Oct 19
1
usage of #import in grDevices/src/qdCocoa.h
I happened to notice that this header file uses
#import <Cocoa/Cocoa.h>
This is the first time I came across the preprocessor directive #import;
the first thing I found about it is this Q&A suggesting it's not portable
nor standard C:
https://stackoverflow.com/q/39280248/3576984
On the other hand, this exact invocation seems pretty common on GitHub
2019 May 27
0
rbind has confusing result for custom sub-class (possible bug?)
Follow-up (inline) on my comment about a potential issue in `[<-.Date`.
On Mon, May 27, 2019 at 9:31 AM Michael Chirico
<michaelchirico4 at gmail.com> wrote:
>
> Yes, thanks for following up on thread here. And thanks again for clearing things up, your email was a finger snap of clarity on the whole issue.
>
> I'll add that actually it was data.table's code at fault
2019 May 27
0
rbind has confusing result for custom sub-class (possible bug?)
On Sun, May 26, 2019 at 6:47 AM Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
>
> On Sun, May 26, 2019 at 4:06 AM Michael Chirico
> <michaelchirico4 at gmail.com> wrote:
> >
> > Have finally managed to come up with a fix after checking out sys.calls()
> > from within the as.Date.IDate debugger, which shows something like:
> >
> > [[1]]
2023 Nov 05
2
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
This is another follow-up to the thread from September "Recent changes to
as.complex(NA_real_)".
A test in data.table was broken by the changes for NA coercion to complex;
the breakage essentially comes from
c(NA, 0+1i)
# vs
c(as.complex(NA), 0+1i)
The former is the output we tested against; the latter is essentially (via
coerceVector() in C) what's generated by our
2023 Nov 06
1
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
Hmm, it is not actually at odds with help(c), it is just that the autocoercion works different that it used to, so that
as.complex(NA) == as.complex(NA_real) == NA_real_+0i)
which now differs from
NA_complex
although both print as NA.
I haven't been quite alert when this change was discussed, but it does look a bit unfortunate that usage patterns like c(NA, 0+1i) does not give complex NA
2019 May 26
0
rbind has confusing result for custom sub-class (possible bug?)
Have finally managed to come up with a fix after checking out sys.calls()
from within the as.Date.IDate debugger, which shows something like:
[[1]] rbind(DF, DF)
[[2]] rbind(deparse.level, ...)
[[3]] `[<-`(`*tmp*`, ri, value = 18042L)
[[4]] `[<-.Date`(`*tmp*`, ri, value = 18042L)
[[5]] as.Date(value)
[[6]] as.Date.IDate(value)
I'm not sure why [<- is called, I guess the
2024 Oct 24
1
Could .Primitive("[") stop forcing R_Visible = TRUE?
Hello,
The "[" primitive operator currently has the 'eval' flag set to 0 in
src/main/names.c. This means that the result of subsetting, whether
R-native or implemented by a method, will never be invisible().
This is a very reasonable default: if the user goes as far as to subset
a value, they probably want to see the result. Unfortunately, there
also exists at least one
2024 Oct 24
1
Could .Primitive("[") stop forcing R_Visible = TRUE?
Thanks for the detailed analysis and proposition Ivan. The patch you
are proposing to base R is
https://github.com/Rdatatable/data.table/issues/6566#issuecomment-2428912338
right?
On Thu, Oct 24, 2024 at 8:48?AM Ivan Krylov via R-devel
<r-devel at r-project.org> wrote:
>
> Hello,
>
> The "[" primitive operator currently has the 'eval' flag set to 0 in
>