-
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
Add an alias for functional version of :=
#3795
Comments
Relatedly it would also help solve this issue: (I suggested the name I think the issue is there's a reason why
Sounds very much so! Are you working in RStudio? There must be a way to define some add-in keyboard shortcuts... |
That was going to be my second proposal. I've just made one and was thinking if it would make sense to add it to data.table proper. add_dot_equal <- function() {
rstudioapi::insertText(text = "`:=`()")
pos <- rstudioapi::getActiveDocumentContext()$selection[[1]]$range
pos$start[2] <- pos$start[2] - 1
pos$end[2] <- pos$end[2] - 1
rstudioapi::setCursorPosition(pos)
} |
I've just realised that this would also make it possible to add columns by reference without explicitly adding names. That is, if dt[, set(list_fun(columns))] I think it would be cool to stick to the naming convention of starting with As far as implementation, I have no idea xD |
Note that there is alternative API for I would prefer to avoid name collision, even if not evaluated. Maybe As for the named list in |
Yes, I guess ultimately it's the same change.
|
Once they will figure that out, looking at My suggestion to address this issue is an alias |
I don't know if many users will ever look at |
I think most (if not all) set* functions take a data.table as input (e.g., setkey, setorder, setcolorder). The most natural syntax to me would be: DT[, .(col1 := new_value, col2 := something)] This way no new symbol is introduced; we simply allow for mixing the already well-known |
In my opinion, that would be more confusing because then the behaviour of I do think its a good point that |
|
Yeah, but I think the point is that |
Maybe simply use a different word other than |
That's fine by me. Is not bad. |
As far as I can tell it's only about changing I wrote this evil hack for a reddit user that wanted this feature :
|
Might I suggest |
Btw, just for completeness, both single quote and double quote also work; i.e. |
Right now when adding multiple columns to a data.table one of the options is to do:
I think that this syntax can be a bit confusing (too many equals) but mainly is hard to write. To get the grave accent, on my keyboard I have to press AltGr + } and then space. It's kind of annoying.
So my modest proposal is to just have an alias for
:=()
that is just a run-off-the-mill common name with no special characters. Maybe (ab)using theset()
function? It would end up something like this:I think it not only reads better, but it's also 87% easier to type.
The text was updated successfully, but these errors were encountered: