Skip to content
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

on = NULL isn't equivalent to missing on #6579

Open
Kodiologist opened this issue Oct 18, 2024 · 0 comments · May be fixed by #6581
Open

on = NULL isn't equivalent to missing on #6579

Kodiologist opened this issue Oct 18, 2024 · 0 comments · May be fixed by #6581

Comments

@Kodiologist
Copy link

> as.data.table(mtcars)[1:5, on = NULL]
Error in `[.data.table`(as.data.table(mtcars), 1:5, on = NULL) : 
  logical error. i is not a data.table, but 'on' argument is provided.

This is problematic when setting on conditionally, as with if or switch. I don't think R allows an expression to return a value that will make missing(on) true. You'd have to construct your [ call with do.call or bquote or something.

This behavior is also inconsistent with the documentation: the usage section of data.table-package states that on defaults to NULL.

Output of sessionInfo()

R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.16.2

loaded via a namespace (and not attached):
[1] compiler_4.4.0 tools_4.4.0    yaml_2.3.8     renv_1.0.5 
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 a pull request may close this issue.

1 participant