Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map in j does not work with .SDcols and other columns as function attributes #2079

Closed
ChandlerLutz opened this issue Mar 26, 2017 · 2 comments

Comments

@ChandlerLutz
Copy link

This may be related to issue #495 #495

library(data.table)
set.seed(1234)
DT <- data.table(a = rnorm(10), b = rnorm(10), c = 10)
##Works as expected
DT[, lapply(.SD, function(x, y) x + y, y = c), .SDcols = c("a", "b")]
##Does not work as expected
DT[, Map(function(x, y) x + y, x = .SD, y = c), .SDcols = c("a", "b")]
@franknarf1
Copy link
Contributor

That's just a misunderstanding of Map. Try

DT[, Map(function(x, y) x + y, x = .SD, y = .(c)), .SDcols = c("a", "b")]

@ChandlerLutz
Copy link
Author

ChandlerLutz commented Mar 27, 2017

Oh okay, great. Thanks! Now works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants