Skip to content

table with explicit factor coercion for integer64 in multiple input case#256

Open
hcirellu wants to merge 8 commits intomainfrom
table_with_factor
Open

table with explicit factor coercion for integer64 in multiple input case#256
hcirellu wants to merge 8 commits intomainfrom
table_with_factor

Conversation

@hcirellu
Copy link
Copy Markdown
Collaborator

@hcirellu hcirellu commented Feb 2, 2026

In main the default table function is used for multiple inputs if the inputs are not all integer64 or mixed with integer. This leads to correct results, but unexpected ordering for the integer64 inputs.

x <- sample(as.integer64(c(132724613L, -2143220989L, -1L, NA, 1L)), rep=TRUE, size = 1000000)
y <- sample(c(TRUE, FALSE), replace = TRUE, size = length(x))
table(x, y, useNA = "ifany")

main:

#              y
# x              FALSE   TRUE
#   <NA>        100165 100002
#   1            99567  99807
#   132724613   100446 100119
#   -1           99881  99922
#   -2143220989 100129  99962

this PR:

#              y
# x              FALSE   TRUE
#   -2143220989 100129  99962
#   -1           99881  99922
#   1            99567  99807
#   132724613   100446 100119
#   <NA>        100165 100002
microbenchmark::microbenchmark(main=table(x, y, useNA="ifany"), PR=table(x, y, useNA="ifany"))
# Unit: milliseconds
#  expr      min       lq     mean   median       uq      max neval
#  main 115.1219 129.1376 143.6508 133.3782 145.9979 362.4458   100
#    PR  83.2341  91.2439 128.9546  97.7848 111.4765 332.4179   100

This PR requires #255 in order to work properly. The commented test in test-highlevel64.R has to be uncommented.

Closes #236

@hcirellu hcirellu marked this pull request as ready for review February 2, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

table.integer64() should not coerce to integer64

1 participant