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 list alias doesn't work with between #2315

Closed
Henrik-P opened this issue Aug 21, 2017 · 4 comments · Fixed by #3518
Closed

dot list alias doesn't work with between #2315

Henrik-P opened this issue Aug 21, 2017 · 4 comments · Fixed by #3518
Assignees
Milestone

Comments

@Henrik-P
Copy link

Henrik-P commented Aug 21, 2017

From ?between:

X = data.table(a = 1:5, b = 6:10, c = c(5:1)) 
X[c %between% list(a, b)]

list can't be replaced by .( ) here:

X[c %between% .(a, b)]
# Error in .(a, b) : could not find function "."
@MichaelChirico
Copy link
Member

MichaelChirico commented Aug 21, 2017 via email

@franknarf1
Copy link
Contributor

@MichaelChirico Of course, it's available in the i, on and by clauses as well. I kind of expect it to work throughout i and j, no matter the form of the expression, anyways. I have a somewhat related SO post https://stackoverflow.com/questions/41228076/using-data-tables-shortcut-in-quoted-expressions

@MichaelChirico
Copy link
Member

MichaelChirico commented Aug 21, 2017 via email

@Henrik-P
Copy link
Author

Just to provide a small background if considering an update of the help text and/or usage of .()

Currently, .( ) is (more or less) explicitly described in:

  • Explicit in the Arguments section of j:

"The expression .() is a shorthand alias to list()")

  • Slightly less explicit in the Arguments section of by:

a list() of expressions of column names: e.g., DT[, .(sa=sum(a)), by=.(x=x>0, y)]

  • Slightly less explicit in the Arguments section of on:

also possible to use .() syntax as X[Y, on=.(a, b)]

  • First j Examples

DT[, .(v)] # same as above, .() is a shorthand alias to list()

  • Quite far down among the i Examples

kDT[.("a")] # same, .() is an alias for list()

Some thoughts:

  1. Given the frequent use of .() in i, and to make the help text more consistent, I think .() could be mentioned explicitly also in the Arguments section of i.
  2. In the i Examples, it would be better to describe .( ) when it first occurs (DT[.("a"), on="x"]).
  3. Either describe exceptions to when .() works (like e.g. my between and in Frank's SO post) or, as Frank wrote, make it work throughout i and j.

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

Successfully merging a pull request may close this issue.

5 participants