Skip to content

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

@franknarf1

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)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions