Why are duplicated column names in data.table with by=.EACHI not fixed?

Open
#7,058 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by running the supplied R and data.table example to reproduce the duplicated column names. Trace the non-equi join using on and by = .EACHI, and check the project documentation for how result columns are constructed. Done means determining whether this is expected behavior and documenting the meaning of both time columns or identifying the correction needed.

Written by the indexing model from the issue text.

Description

non-equi joins

A while ago I created a stackoverflow question:
https://stackoverflow.com/questions/78994519/why-are-duplicated-column-names-in-data-table-with-by-eachi-not-fixed

The question there is: Why does the result of the following operation

library(data.table)
dt <- data.table(time = c(13, 20, 26))
dt[,time10 := time - 10]
dt[dt, on = .(time >= time10, time <= time), .N,by = .EACHI]

contain twice a column named "time"?

    time  time     N
   <num> <num> <int>
1:     3    13     1
2:    10    20     2
3:    16    26     2

I personally feel like this should not happen. I also do not understand, where the first column named "time" comes from.

I use R 4.5.0 and data.table 1.17.2

In case this is a bug, I could elaborate more, otherwise feel free to close this issue.

Is there any documentation for what these two "time" columns mean and how they are constructed?

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.