Skip to content

Commit 8e4783d

Browse files
More precise wording about add/remove
1 parent 5520b6a commit 8e4783d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

R/data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ replace_dot_alias = function(e) {
11951195
# ok=-1 which will trigger setalloccol with verbose in the next
11961196
# branch, which again calls _selfrefok and returns the message then
11971197
if ((ok<-selfrefok(x, verbose=FALSE))==0L) # ok==0 so no warning when loaded from disk (-1) [-1 considered TRUE by R]
1198-
if (is.data.table(x)) warningf("A shallow copy of this data.table was taken so that := can add %d new columns by reference. At an earlier point, this data.table was copied by R (or was created manually using structure() or similar). Avoid names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. It's also common for data.table-unaware packages to produce affected tables. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.", length(newnames))
1198+
if (is.data.table(x)) warningf("A shallow copy of this data.table was taken so that := can add or remove %d columns by reference. At an earlier point, this data.table was copied by R (or was created manually using structure() or similar). Avoid names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. It's also not unusual for data.table-agnostic packages to produce tables affected by this issue. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.", length(newnames))
11991199
# !is.data.table for DF |> DT(,:=) tests 2212.16-19 (#5113) where a shallow copy is routine for data.frame
12001200
if ((ok<1L) || (truelength(x) < ncol(x)+length(newnames))) {
12011201
DT = x # in case getOption contains "ncol(DT)" as it used to. TODO: warn and then remove

0 commit comments

Comments
 (0)