-
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
rolling join keeps only one on
column, takes name from x table and values from i table
#4005
Comments
A slightly better way to do this is: library(data.table)
x <- data.table(x1=letters[1:3], x2=c(10,20,30))
y <- data.table(y1=letters[4:6], y2=c(11,21,31))
x[y, roll = "nearest", on = .(x2 = y2), .(x1, x2 = x.x2, y1, y2 = i.y2)] |
At a glance that's this PR? |
@MichaelChirico yes, I think keeping both columns is the best solution, as this is a right join it feels both wrong to me to remove from the original table (x) and to the left table(i). @shrektan, thanks, it does improve things here, in my real case I have many more columns and wish to keep all on both sides however so I don't think this can work. |
I tweaked a little bit and hope it may help before the feature finally gets there. Haven't read #3093 through but I think the simplest implementation for this feature (well, occationally, I need this feature as well) is to just add an option in A more general wrapper...library(data.table)
x <- data.table(x1=letters[1:3], x2=c(10,20,30))
y <- data.table(y1=letters[4:6], y2=c(11,21,31))
vars <- c(names(x), names(y))
vars[vars == "x2"] <- "x.x2"
vars[vars == "y2"] <- "i.y2"
x[y, roll = "nearest", on = .(x2 = y2), c(vars), with = FALSE] |
Thanks @shrektan |
Well, the default doesn't that bad... at least for the finance guys... like myself, because many cases that I encounter are more about "query" the However, I incline to your opinion: either specifying the only desired columns or just return all the columns from x and y... |
I second @moodymudskipper that naming convention on join is confusing and less intuitive. Since I think the default behavior should change and be consistent that it also keeps the right column name as join result. |
This got me very confused :
I would much prefer to keep both
x2
andy2
, and if we must keep only one column I would much rather have the column name fit the original values.The workaround I found looks quite awful, can I do better ?
The text was updated successfully, but these errors were encountered: