A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Rdatatable/data.table/issues/733 below:

x[i, j, by=.] where `i` is a data.table and `j` contains expressions from `i` should/could work as well · Issue #733 · Rdatatable/data.table · GitHub

Referring to this SO post from @juancentro:

dta <- data.table(idx=1:3, vala=4:6, fidx = c("a", "a", "b"), key="idx")
dtb <- data.table(idx=c(1,4), valb=c(10,11), key="idx")

# (1)
dta[dtb, sum(vala), by=fidx]
#    fidx V1
#1:    a  4
#2:   NA NA

# (2)
dta[dtb, sum(valb), by=fidx]
# Error in `[.data.table`(dta, dtb, sum(valb), by = fidx) : 
#   object 'valb' not found

It would be nice to have case (2) returning the right result as well.

That is, as @juancentro and @eantonya mentioned:

dta[dtb, sum(valb), by=fidx] == dta[dtb][, sum(valb), by=fidx]

would be great!

Thanks to @juancentro for reporting on SO.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4