Skip to content

Commit 84452da

Browse files
Update vignettes/datatable-reference-semantics.Rmd
Co-authored-by: Benjamin Schwendinger <[email protected]>
1 parent 891f505 commit 84452da

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vignettes/datatable-reference-semantics.Rmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,9 @@ However we could improve this functionality further by *shallow* copying instead
365365
```
366366
### c) Selecting columns: `$` vs `[, col]`
367367
368-
When selecting a column as a vector, `DT$col` and `DT[, col]` have a key difference: `DT$col` may return a reference to the data, while `DT[, col]` always returns a copy.
369-
370-
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:
368+
When you extract a single column as a vector there is a subtle but important difference: `DT$col` may return a reference to the internal column, while `DT[, col]` always returns a copy. Because of that, a variable created with `DT$col` can change if you later modify DT by reference.
371369
370+
A short example:
372371
```{r}
373372
DT = data.table(a = 1:3)
374373

0 commit comments

Comments
 (0)