-
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
patterns in .SDcols #1878
Comments
I'd like to add, that It is often needed to select columns with or to remove multiple columns, e.g. or to make new column names: These would be much shorter with Alternatively, it would be handy to have a special symbol for column names, selected in |
names(.SD) should suffice... On Oct 26, 2016 12:37 PM, "ksavin" [email protected] wrote:
|
Forgot I am in fact using |
I do regularly things like |
Another one I tend to use is |
Just as a reference to a SO question, please update it there also if it got implemented :-) |
I wrote library(hutils)
library(data.table)
dt <- data.table(x1 = 1, x2 = 2, y = 0)
select_grep(dt, "x")
#> x1 x2
#> 1: 1 2
select_grep(dt, "x", .and = "y")
#> x1 x2 y
#> 1: 1 2 0
select_grep(dt, "x", .and = "y", .but.not = "x2")
#> x1 y
#> 1: 1 0 Created on 2018-05-19 by the reprex package (v0.2.0). |
I thought I've seen this FR before, but couldn't find it.
Would be nice if we could specify column names using regex expressions in
.SDcols
. Currently one has to do something like.SDcols = grep("mypattern", names(myDT))
, which you can't chain on, and is pretty fragile.Perhaps the
patterns
function frommelt
can be reused here, making the syntax.SDcols = patterns("mypattern")
.The text was updated successfully, but these errors were encountered: