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

dot alias not understood as expected in by/keyby #2447

Open
MichaelChirico opened this issue Oct 27, 2017 · 2 comments
Open

dot alias not understood as expected in by/keyby #2447

MichaelChirico opened this issue Oct 27, 2017 · 2 comments

Comments

@MichaelChirico
Copy link
Member

MichaelChirico commented Oct 27, 2017

I think there are a couple of issues on similar fronts addressing that we should be more consistent about how/when . is understood in data.table and more specifically within [.data.table calls. Here's a new one I came across today:

DT = data.table(a = 1:10, b = 10:1)
DT[ , mean(b), by = {
  a2 = a^2
  .(a2mod5 = a2 %% 5)
}]

This returns an error since evaluation looks for the . function (i.e., the call has not replaced . with list) (replacing . with list, this evaluates as expected):

Error in .(b2mod5 = b2%%5) : could not find function "."

Contrast this to something similar in j:

DT = data.table(a = 1:10, b = 10:1)
DT[ , {
  b2 = b^2
  .(b2mod5 = sum(b2 %% 5))
}, by = a %% 3]
#    a b2mod5
# 1: 1      6
# 2: 2      6
# 3: 0      8

Some related issues: #2391, #1912, #852, a few others I can't find just now

@Henrik-P
Copy link

Perhaps among the 'few others': dot list alias doesn't work with between

@MichaelChirico
Copy link
Member Author

MichaelChirico commented Oct 28, 2017 via email

@jangorecki jangorecki added this to the 1.12.11 milestone Jul 2, 2020
@mattdowle mattdowle modified the milestones: 1.13.1, 1.13.3 Oct 17, 2020
@jangorecki jangorecki modified the milestones: 1.14.3, 1.14.5 Jul 19, 2022
@jangorecki jangorecki modified the milestones: 1.14.11, 1.15.1 Oct 29, 2023
@jangorecki jangorecki removed this from the 1.16.0 milestone Nov 6, 2023
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

4 participants