Skip to content

Commit 1640a18

Browse files
committed
rm DT for env arg
1 parent 9fc2774 commit 1640a18

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

man/data.table.Rd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,6 @@ print(DT["b", v2:=84L, on="x"]) # subassign to new column by reference (NA
404404
DT[, m:=mean(v), by=x][] # add new column by reference by group
405405
# NB: postfix [] is shortcut to print()
406406

407-
# Injecting function into env parameter
408-
DT <- data.table(a = rep(1:2, each = 5), b = 1:10)
409-
410-
DT[, .(f=f(b), gval=g(b)), by = a, env = list(f = "sum", g=mean), verbose=TRUE]
411-
412407
# advanced usage
413408
DT = data.table(x=rep(c("b","a","c"),each=3), v=c(1,1,1,2,2,1,1,2,2), y=c(1,3,6), a=1:9, b=9:1)
414409

@@ -424,6 +419,9 @@ DT[, list(MySum=sum(v),
424419
MyMax=max(v)),
425420
by=.(x, y\%\%2)] # by 2 expressions
426421

422+
DT[, .(f=f(a), m=g(a)), by=b, verbose=TRUE,
423+
env=list(f="sum", g=mean, b="x")] # subtitution via env arg
424+
427425
DT[, .(a = .(a), b = .(b)), by=x] # list columns
428426
DT[, .(seq = min(a):max(b)), by=x] # j is not limited to just aggregations
429427
DT[, sum(v), by=x][V1<20] # compound query

0 commit comments

Comments
 (0)