Clarification on use of .. (dot dot)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- r
- Domain
- documentation
Research direction
Start with the news-page documentation quoted in the issue and compare the shown DT[,mpg], DT[,get(colname)], and DT[,..colname] examples, including their behavior with first(). Clarify the documented distinction between selecting column names and selecting column values, and ensure the examples accurately describe the expected results.
Written by the indexing model from the issue text.
Description
The .. feature for fetching column names stored in character vectors is documented in the news page as:
When j is a symbol prefixed with .. it will be looked up in calling scope and its value taken to be column names or numbers.
This implies that it works similarly to typing the column name directly (had it been known at the time of writing the code). However that does not seem to be the case. E.g.
DT <- data.table(mtcars)
colname <- "mpg"
Both DT[,mpg] and DT[,get(colname)] return a vector of values. But DT[,..colname] returns a data.table.
This confused me because it has implications for calling functions on the column. E.g. I attempted to use first(): both DT[,first(mpg)] and DT[,first(get(colname))] return 21. But DT[,first(..colname)] returns 'mpg', which is the column name.
If this is expected behaviour, please will the documentation clarify the use? Thank you
- 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 ·
-
bug fread
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Rdatatable/data.table#7896 · 1 reaction ·
All issues in Rdatatable/data.table
Similar issues
-
documentation pkg infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
jbkunst/highcharter#849 ·
-
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