Skip to content

how to subset the data frame by lines

4 messages · Jie Tang, Jorge I Velez, Bert Gunter +1 more

#
Please read An Introduction to R, which ships with every copy of R,
where you will learn how to properly subscript data frames and lists,
among other things. There is a reason for such tutorials -- they
enable you to avoid elementary mistakes like this and wasting time and
effort with such posts as this.

-- Bert
On Wed, Aug 1, 2012 at 2:13 PM, Jie Tang <totangjie at gmail.com> wrote:

  
    
#
Specifically note that, unlike C, R has true multidimensional arrays
which are more than pointer jumps: the practical result of this is
that you want to use a single subsetting ( x[i,j] ) and specify them
both in one call  -- x[i][j] instead gives you the "j"th element of
the "i"th element which may or may not exist, but likely isn't what
you are looking for.
On Wed, Aug 1, 2012 at 4:27 PM, Bert Gunter <gunter.berton at gene.com> wrote:
You really just want this:

aa[2, ]

Second row -- not specifying the column returns all of them. And note
that we are 1-based in our indexing here!

Michael