-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
un-necessary warning for dcast on int columns with fun.aggregate=min/max #5512
Comments
Tests you found are different use cases, where this warning is good. They come from base R rather than data.table. I don't see exactly how we call R from dcast that those warnings are raised, that should be checked, but to suppress the warning we probably have to catch warnings, and re-raise any, excluding this particular one. |
You may avoid the warning by explicitly providing the The reason for this warning is that data.table is guessing what should be filled using The root cause of this is that, Probably we should suppress the warning here: Lines 28 to 30 in cb8aeff
|
this is related to #5390 where there is an example with fill=NULL, where dcast uses fun.aggregate to compute a fill value, but the fill value is actually not used/needed. For example, below the fill value is actually needed and used in three places, so the warning is reasonable. > dcast(DT, num ~ chr, min, value.var="int")
Key: <num>
num a b
<num> <int> <int>
1: 1 1 NA
2: 2 NA 2
3: 3 NA 3
Warning message:
In dcast.data.table(DT, num ~ chr, min, value.var = "int") :
NAs introduced by coercion to integer range However in the code below the fill value is not actually used, so getting this warning is confusing, because the fill value is computed but not used: > dcast(DT, . ~ chr, min, value.var="int")
Key: <.>
. a b
<char> <int> <int>
1: . 1 2
Warning message:
In dcast.data.table(DT, . ~ chr, min, value.var = "int") :
NAs introduced by coercion to integer range Therefore I would say that the fix should be to update dcast so that it only computes the default fill value if it is actually needed in the output. |
* delete old commented code * new test for no warning fails * only compute default fill if missing cells present * any_NA_int helper * bugfix #5512 * Update src/fcast.c Co-authored-by: Xianying Tan <shrektan@126.com> * Update src/fcast.c Co-authored-by: Xianying Tan <shrektan@126.com> * mention warning text * const int args * add back ithiscol * get pointer before for loop * add test case from Michael * test min(dbl) and no warning when fill specified * Revert "delete old commented code" This reverts commit 2886c4f. * use suggestions from Michael * rm inline any_NA_int since that causes install to fail * clarify comment * link 5390 * mymin test fails * compute some_fill using anyNA in R then pass to C * Update R/fcast.R Co-authored-by: Michael Chirico <michaelchirico4@gmail.com> * Update R/fcast.R Co-authored-by: Michael Chirico <michaelchirico4@gmail.com> * dat_for_default_fill is zero-row dt * !length instead of length==0 * new dcast tests with fill=character * dat_for_default_fill is dat again, not 0-row, because that causes some test failure --------- Co-authored-by: Xianying Tan <shrektan@126.com> Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
Hi! I noticed a warning which I think is potentially confusing and should be removed:
The result above is as expected, so I would suggest removing this warning to avoid confusion. (because of this warning, I mistakenly thought that the result was not computed correctly, but in fact the result is fine)
It seems that this issue is specific to when
value.var
is type integer, andfun.aggregate
ismin
ormax
. No warning happens when we do min/max on numeric column:And no warning happens when we do mean/sd on int column:
I searched the tests for this warning message and I found:
The text was updated successfully, but these errors were encountered: