[R] Getting subsets of a data frame
Fernando Saldanha
fsaldan1 at gmail.com
Sat Apr 16 05:07:01 CEST 2005
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 == 1:1
[1] TRUE
Then why isn't sw[,1] = sw[, 1:1] a data frame?
FS
More information about the R-help
mailing list