Skip to content
Prev 67819 / 398506 Next

Getting subsets of a data frame

I was reading in the Reference Manual about Extract.data.frame.

There is a list of examples of expressions using [ and [[, with the
outcomes. I was puzzled by the fact that, if sw is a data frame, then

sw[, 1:3]

is also a data frame,

but 

sw[, 1]

is just a vector.

Since R has no scalars, it must be the case that 1 and 1:1 are the same:
[1] TRUE
 
Then why isn't sw[,1] = sw[, 1:1] a data frame?

FS