subsetting inconsitent with NULL vs. ..variable
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the reported difference between dt[, NULL] and dt[, ..k] using the example in the issue, including k <- NULL. Trace the data.table subsetting entry point for these two expressions and add a regression test covering identical results; done means both expressions return the same result.
Written by the indexing model from the issue text.
Description
when subsetting on a NULL column, data.table returns an expected NULL
however, when subsetting on a NULL variable, data.table returns a Null data.table (0 rows and 0 cols). I would expect both these scenarios to produce identical results
this is an edge case and fairly easy to work around, but logging the inconsistency
> dt <- data.table(A=1:3, B=4:6)
> k <-1:2
> identical(dt[, 1:2], dt[, ..k])
[1] TRUE
> k <- c("A","B")
> identical(dt[, c("A","B")], dt[, ..k])
[1] TRUE
> k <- NULL
> identical(dt[, NULL], dt[, ..k])
[1] FALSE
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] IBrokers_0.9-12 doParallel_1.0.14 iterators_1.0.11 foreach_1.5.1 data.table_1.12.6 curl_3.3 rvest_0.3.4 xml2_1.2.2
[9] quantmod_0.4-15 TTR_0.23-5 xts_0.11-2 zoo_1.8-6 RODBC_1.3-16 plotrix_3.7-6 RevoUtils_11.0.3 checkpoint_0.4.4
[17] RevoUtilsMath_11.0.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 codetools_0.2-16 lattice_0.20-38 R6_2.3.0 grid_3.5.3 magrittr_1.5 httr_1.4.1 tools_3.5.3 compiler_3.5.3
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·