Error occurs when using fsort(x, decreasing=TRUE)
It seems that internally 'order' cannot be converted to -1 when using: forderv(x, order = !decreasing, na.last = na.last)
# Minimal reproducible example
# use default examples, error occurs both version 1.10.4.3 or 1.10.5
x = runif(1e6)
system.time(ans1 <- sort(x, method="quick"))
system.time(ans2 <- fsort(x))
fsort(x, decreasing=T)
Error in forderv(x, order = !decreasing, na.last = na.last) :
x is a single vector, length(order) must be =1 and it's value should be 1 (ascending) or -1 (descending).
姝ゅ: Warning message:
In fsort(x, decreasing = T) :
Input is not a vector of type double. New parallel sort has only been done for double vectors so far. Invoking relatively inefficient sort using order first.
# Output of sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS
Matrix products: default
BLAS/LAPACK: /opt/openblas/lib/libopenblasp-r0.2.20.dev.so
locale:
[1] LC_CTYPE=zh_TW.UTF-8 LC_NUMERIC=C LC_TIME=lzh_TW LC_COLLATE=zh_TW.UTF-8
[5] LC_MONETARY=lzh_TW LC_MESSAGES=zh_TW.UTF-8 LC_PAPER=lzh_TW LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=lzh_TW LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.10.5
loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1 yaml_2.1.18
Interesting. There are two problems here:
x is not a double, while in reality it is.fsort falls back to forderv(x, order = !decreasing, na.last = na.last) for the seemingly no-double x, the order argument is not handed over correctly. It should be -1 for decreasing (according to documentation), not 0 (!decreasing) as implemented. Will have a look when I can.I have investigated the two problems:
decreasing=TRUE, fsort falls back to forder no matter if double or integer. This should be mentioned by the warning.I have created a fix, but during testing, found another bug #2772 where fsort utterly fails on vectors with NA. This needs to be fixed in order for the tests to run properly. If it turns out to be infeasible to fix on short notice, I will adapt the tests and fix this issue before the other one.