Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upzero length .SDcols #1789
zero length .SDcols #1789
Comments
|
Slightly related to #1269. |
|
As a note, there is a (very mild) inconsistency between zero-length character and zero-length integer DT <- data.table(x = 1, y = 2, z = 3)
DT[, .SD, .SDcols = integer(0)]
# Error in `[.data.table`(DT, , .SD, .SDcols = integer(0)) :
# .SDcols is numeric but has both +ve and -ve indices
DT[, .SD, .SDcols = character(0)]
# Null data.table (0 rows and 0 cols)In my view the |
It would be nice if .SDcols could be zero length. In #1786 we discussed this code which works but a special case had to be made for the situation where there were no numeric columns.
It would be nice if .SDcols could allow the specification of no columns so that this would work even in the case that iris has no numeric columns.
(Incidentally it would also be nice if nums could be logical so that we could have
nums <- sapply(iris.dt, is.numeric). That works in .SDcols= but not on the LHS of := .)