[R] subsetting a list of matrices

Federico Calboli f.calboli at imperial.ac.uk
Tue Feb 28 18:14:39 CET 2006


Hi All,

I have a list of matrices:

> x
     [,1] [,2]
[1,]    1    4
[2,]    2    5
[3,]    3    6
> y
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]   18   21   24   27   30   33
[2,]   19   22   25   28   31   34
[3,]   20   23   26   29   32   35
> z =list(x,y)

I want to create a second list that is has a subset each matrix in the
list subsetting so I get the 2nd and 3rd row of each (and all columns).

How could I do that (apart from looping)?

Regards,

Federico Calboli

-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com




More information about the R-help mailing list