Skip to content

DT[, .SD] doesn't seem to retain secondary indices #1709

Description

@arunsrinivasan
require(data.table)
dt = data.table(x=1:5, y=6:10)
setindex(dt, x)

indices(dt) # [1] "x"
indices(dt[, .SD]) # NULL

Activity

  1. MarkusBonsch commented on Feb 14, 2018

    @MarkusBonsch
    Contributor

    @arunsrinivasan I think, this is not a bug, but a feature request since it doesn't break anything or lead to incorrect results.

  2. jangorecki commented on Jan 7, 2024

    @jangorecki
    Member
    require(data.table)
    dt = data.table(x=1:5, y=6:10)
    setindex(dt, x)
    
    indices(dt)
    #[1] "x"
    indices(dt[, .SD])
    #[1] "x"

    it now does retain index.
    we can close this issue by adding a unit test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions