try this:

m <- matrix(1:9, nrow=3, dimnames=list(LETTERS[1:3], letters[1:3]))
l <- list(m1=m, m2=m*2, m3=m*3)

lapply(l, "[", 1, 1)

# or

sapply(l, "[", 1, 1)


I hope it helps.

Best,
Dimitris


On 11/17/2010 3:01 PM, soeren.vo...@eawag.ch wrote:
A list contains several matrices. Over all matrices (list elements) I'd like to 
access one matrix cell:

m<- matrix(1:9, nrow=3, dimnames=list(LETTERS[1:3], letters[1:3]))
l<- list(m1=m, m2=m*2, m3=m*3)
l[[3]] # works
l[[3]][1:2, ] # works
l[[1:3]][1, 1] # does not work

How can I slice all C-c combinations in the list?

Sören


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to