[R] r data structures
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Aug 16 23:52:32 CEST 2012
On Thu, Aug 16, 2012 at 5:44 PM, MacQueen, Don <macqueen1 at llnl.gov> wrote:
> Whereas for a matrix or data frame, one must supply *two* index values
> (even if one of them may be omitted)
> mydf[ 1 , 3 ]
> mydf[ , 5 ]
>
> mymat[ 2:5 , ]
> mymat[ 3 , 4:6 ]
> are valid statements.
>
Not quite:
x <- matrix(rev(1:9), ncol = 3)
x[5]
x[2:6]
x <- data.frame(x)
x[3]
I understand this as meaning, when you don't use special 2D indexing,
R falls back on 1D indexing behavior given by the relevant superclass:
vector for matrix and list for data.frame.
Cheers,
RMW
More information about the R-help
mailing list