You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit effc48f
Browse filesBrowse the repository at this point in the historyBrowse files
# [ called from a scope that is not data.table-aware (!cedta()) behaves like [.data.frame.
525
+
# i, j and drop are passed on as promises, so their missingness reaches [.data.frame unchanged.
526
+
# nargs is nargs() of the [.data.table call.
527
+
.dt_cedta_fallback=function(x, i, j, drop, jsub, nargs, missing_i, missing_drop) {
528
+
# Fix for #500 (to do)
529
+
if (jsub %iscall% c(":=", "let")) {
530
+
# Throw a specific error message
531
+
stopf("[ was called on a data.table in an environment that is not data.table-aware (i.e. cedta()), but '%s' was used, implying the owner of this call really intended for data.table methods to be called. See vignette('datatable-importing') for details on properly importing data.table.", as.character(jsub[[1L]]))
532
+
}
533
+
Nargs=nargs- (!missing_drop)
534
+
ans=if (Nargs<3L) { `[.data.frame`(x,i) } # drop ignored anyway by DF[i]
535
+
elseif (missing_drop) `[.data.frame`(x,i,j)
536
+
else `[.data.frame`(x,i,j,drop)
537
+
# added is.data.table(ans) check to fix bug #81
538
+
if (!missing_i&& is.data.table(ans)) setkey(ans, NULL) # drops index too; tested by plyr::arrange test in other.Rraw
# capture parent.frame() changes once as calling scope
541
559
callenv= parent.frame()
542
-
if (!cedta()) {
543
-
# Fix for #500 (to do)
544
-
if (substitute(j) %iscall% c(":=", "let")) {
545
-
# Throw a specific error message
546
-
stopf("[ was called on a data.table in an environment that is not data.table-aware (i.e. cedta()), but '%s' was used, implying the owner of this call really intended for data.table methods to be called. See vignette('datatable-importing') for details on properly importing data.table.", as.character(substitute(j)[[1L]]))
547
-
}
548
-
Nargs= nargs() - (!missing_drop)
549
-
ans=if (Nargs<3L) { `[.data.frame`(x,i) } # drop ignored anyway by DF[i]
550
-
elseif (missing_drop) `[.data.frame`(x,i,j)
551
-
else `[.data.frame`(x,i,j,drop)
552
-
# added is.data.table(ans) check to fix bug #81
553
-
if (!missing_i&& is.data.table(ans)) setkey(ans, NULL) # drops index too; tested by plyr::arrange test in other.Rraw
554
-
return(ans)
555
-
}
560
+
# cedta() and nargs() depend on this frame so are evaluated here
561
+
if (!cedta()) return(.dt_cedta_fallback(x, i, j, drop, substitute(j), nargs(), missing_i, missing_drop))
556
562
if (!missing_verbose) {
557
563
if (!is.integer(verbose) &&!is.logical(verbose)) stopf("verbose must be logical or integer")
558
564
if (length(verbose)!=1L|| anyNA(verbose)) stopf("verbose must be length 1 non-NA")
test(3.06, key(naive(DT[])), "b") # key retained when i is missing, dropped otherwise
186
+
test(3.07, key(naive(DT[1:3, ])), NULL)
187
+
test(3.08, naive(DT[, a := 1L]), error="[ was called on a data.table in an environment that is not data.table-aware (i.e. cedta()), but ':=' was used")
188
+
test(3.09, naive(DT[, let(a = 1L)]), error="but 'let' was used")
0 commit comments