Closed
Description
Submitted by: Arun ; Assigned to: Arun ; R-Forge link
Best with an example:
require(data.table) ## 1.9.3
DT <- data.table(x=1:5, x=6:10)
DT[, 1:2, with=FALSE]
It's clear that the columns to choose are 1st and 2nd. Still, it gives back just the first column:
x x
1: 1 1
2: 2 2
3: 3 3
4: 4 4
5: 5 5
data.frame does this very nicely, although it renames the columns (which we don't have to do).
as.data.frame(DT)[, 1:2]
x x.1
1 1 6
2 2 7
3 3 8
4 4 9
5 5 10