-
Notifications
You must be signed in to change notification settings - Fork 991
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
Allow ! on LHS of := #4031
Comments
I've already been confused by the use of I think this ambiguity can be avoided by having select helpers in the style of https://www.rdocumentation.org/packages/dplyr/versions/0.7.2/topics/select_helpers We would have :
And then all other useful select helpers would work as well :
In tidy select those helpers return numeric indices, so to use several helpers we need to use set functions like So for this to work the select helpers should detect the data table context and Allowing functions on the rhs would go with this quite well, so we could do things like :
|
I am not sure about keep = c('Species', 'Sepal.Width')
dt[ , setdiff(names(.SD), keep) := NULL]
setcolorder(dt, keep) |
Upvoting this feature. Column selection and deletion are bread and butter of data manipulation. It is not intuitive to keep = c("Species", "Sepal.Width")
dat[ , keep := KEEP] or a more general but less direct approach, as proposed by @MichaelChirico. This is also similar to typing dat[ , !keep := NULL]
# or
dat[ , -keep := NULL] |
Another route would be a helper function on
|
With dt[ , names(.SD) := NULL, .SDcols=!keep] Closing here, please open other FRs if there's still something missing. |
Related to #571, #1710, a few others about allowing NSE on LHS of :=.
Based on the example given here:
#4030 (comment)
Would be quite natural/less clumsy/available for chaining to do:
The text was updated successfully, but these errors were encountered: