[R] subsetting a matrix

Rajarshi Guha rxg218 at psu.edu
Tue Sep 30 21:58:43 CEST 2003

On Tue, 2003-09-30 at 15:51, Jason Turner wrote:
> (Ted Harding) wrote:
> > On 30-Sep-03 Rajarshi Guha wrote:
> > 
> >>Hi,
> >>  I'm trying to take a set of rows and columns out of a matrix. I hve
> >>been using the index aray approach. My overll matrix is X and is 179 x
> >>65. I want to take out 4 columns and 161 rows.
> ...
> This is documented in "An Introduction to R", under the section "Arrays 
> and Matricies".  There's lots of good stuff in there.  From R:
> help.start()
> And click on "An Introduction to R".
> The short answer to this particular question:
> a) negative indicies remove rows or columns.  Since you only want to 
> remove 4 columns, I'd use that.
> b) Since you only want to keep 18 rows, I'd use the numbers of the rows 
> you want to keep.

Thanks for all the answers. I had been writing loops and extracting
elements - I've been spending too much time in C :-/

Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
Build a system that even a fool can use and only a fool will want to use

More information about the R-help mailing list