[R] slicing list with matrices

Benno Pütz puetz at mpipsykl.mpg.de
Wed Nov 17 15:40:25 CET 2010


Maybe 

	lapply(l,function(x){x[1,1]})
or
	unlist(lapply(l,function(x){x[1,1]})) 

does what you want?

	Benno 

Am 17.Nov.2010 um 15:01 schrieb soeren.vogel at eawag.ch:

> 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



More information about the R-help mailing list