Hi! I noticed a warning which I think is potentially confusing and should be removed:
> library(data.table)
data.table 1.14.5 IN DEVELOPMENT built 2022-11-01 15:48:48 UTC; root using 6 threads (see ?getDTthreads). Latest news: r-datatable.com
> DT <- data.table(chr=c("a","b","b"), int=1:3)[, num := as.numeric(int)]
> dcast(DT, chr ~ ., list(min,max), value.var="int")
Key: <chr>
chr int_min int_max
<char> <int> <int>
1: a 1 1
2: b 2 3
Warning messages:
1: In dcast.data.table(DT, chr ~ ., list(min, max), value.var = "int") :
NAs introduced by coercion to integer range
2: In dcast.data.table(DT, chr ~ ., list(min, max), value.var = "int") :
NAs introduced by coercion to integer range
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, and fun.aggregate is min or max. No warning happens when we do min/max on numeric column:
> dcast(DT, chr ~ ., list(min,max), value.var="num")
Key: <chr>
chr num_min num_max
<char> <num> <num>
1: a 1 1
2: b 2 3
And no warning happens when we do mean/sd on int column:
> dcast(DT, chr ~ ., list(mean,sd), value.var="int")
Key: <chr>
chr int_mean int_sd
<char> <num> <num>
1: a 1.0 NA
2: b 2.5 0.7071068
I searched the tests for this warning message and I found:
froll.Rraw:414:test(6000.114, frollmean(1:5, Inf), error="n must be positive integer values", warning="NAs introduced by coercion*")
froll.Rraw:416:test(6000.115, frollmean(1:5, c(5, Inf)), error="n must be positive integer values", warning="NAs introduced by coercion*")
nafill.Rraw:125:test(3.07, nafill(x, fill="asd"), x, warning=c("Coercing.*character.*integer","NAs introduced by coercion"))
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.varis type integer, andfun.aggregateisminormax. 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: