Let's say I have a dt data table.
dt = as.data.table(c(0,1,2,3))
I would like to know why the dt behavior is different in the following two lines of code.
dt[,V1]
dt[,"V1",with=F]
In particular, the first row produces a numeric vector, while the second row creates a data table.
I would like to create a function that would allow me to dynamically retrieve single columns by passing a row (with c = F) and using this output in some other functions. As now, the behavior in the latter case may cause an error in some functions, such as ecdf and hist, which do not accept the data.frame or data.table file.
Here is the workaround I made.
as.data.frame(dt[,"V1",with=F])[,1]
: , ecdf hist. . , dt[,"V1",with=F] dt[,V1]?