Clarify $ vs [, col] behavior in docs (#7369)#7381
Merged
ben-schwen merged 10 commits intomasterfrom Oct 25, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7381 +/- ##
=======================================
Coverage 99.12% 99.12%
=======================================
Files 85 85
Lines 16637 16637
=======================================
Hits 16492 16492
Misses 145 145 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ben-schwen
reviewed
Oct 22, 2025
ben-schwen
reviewed
Oct 22, 2025
ben-schwen
reviewed
Oct 22, 2025
jangorecki
reviewed
Oct 22, 2025
ben-schwen
reviewed
Oct 22, 2025
ben-schwen
approved these changes
Oct 22, 2025
Member
ben-schwen
left a comment
There was a problem hiding this comment.
Basically LGTM. Some wording sounds unusual and too eloborate for our usual style.
jangorecki
reviewed
Oct 22, 2025
| This means a variable created with `$` can change if the `data.table` is modified later, which can be unexpected. A single example demonstrates this behavior and how `copy()` provides a solution: | ||
|
|
||
| ```{r} | ||
| library(data.table) |
Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
Member
|
What about DT[["a"]] |
ben-schwen
reviewed
Oct 25, 2025
Member
|
TY! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #7369
This PR clarifies the difference between DT$col and DT[, col] when selecting columns.
datatable-reference-semantics.Rmd:
Added a short section explaining that DT$col may return a reference, while DT[, col] always returns a copy. Included a minimal example.
datatable-faq.Rmd:
Added a brief note and link to the semantics vignette for details.
hi @jangorecki can you please review this when you have time ,and if any improvements are needed let me know .
thank you for your time.
thanks .