Skip to content

[consistency] DT[,0,with=FALSE] should return an empty data.table #1140

Closed

Description

@franknarf1

It's currently inconsistent with data.frame subsetting:

DF <- data.frame(a=1:5); DT <- data.table(DF)
DF[,0]
# data frame with 0 columns and 5 rows
DT[,0,with=FALSE]
# Error in `[.data.table`(DT, , 0, with = FALSE) : j out of bounds

I don't think it's possible to have a data.table with "0 columns and 5 rows" (as for DF[,0]). Maybe it could return a Null data.table, as [.listof(DT,0) does...?

(Short thread on mailing list)

Activity

  1. franknarf1 commented on May 6, 2015

    @franknarf1
    ContributorAuthor

    Sorry, not sure how to add the consistency tag; and I'm not sure if this is a bug, a feature request or neither.

  2. added this to the v1.9.6 milestone on Sep 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions