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
Closed

dot list alias doesn't work with `between` #2315

Henrik-P opened this issue Aug 21, 2017 · 4 comments
Assignees
Milestone

Comments

@Henrik-P
Copy link
Contributor

@Henrik-P 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 MichaelChirico commented Aug 21, 2017

@franknarf1
Copy link
Contributor

@franknarf1 franknarf1 commented Aug 21, 2017

@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 MichaelChirico commented Aug 21, 2017

@Henrik-P
Copy link
Contributor Author

@Henrik-P Henrik-P commented Aug 22, 2017

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.
jangorecki added a commit that referenced this issue Apr 22, 2019
@jangorecki jangorecki self-assigned this Apr 22, 2019
@mattdowle mattdowle added this to the 1.12.4 milestone Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.