Dear List, Let's say I have a list whose components are 2 matrices (as exemplified in the "mylist" object below). I'd like to create a list with components being 4 matrices based on an logical index vector. is there a way to simplify what I'm doing to obtain the results in "mylist2"? I'd like something that would work on an arbitrary number of elements in "mylist".
mylist <- list(matrix(1:9,3,3), matrix(10:18,3,3)) index1 <- c(TRUE,FALSE,TRUE) index2<- c(FALSE,TRUE,TRUE) mylist2 <- list(mylist[[1]][,index1], mylist[[1]][,index1==FALSE], mylist[[2]][,index2], mylist[[2]][,index2==FALSE]) Thanks in advance, Axel. [[alternative HTML version deleted]] ______________________________________________ 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.