HI, Does this work for you? mapply(function(x) x=="B",m) [,1] [,2] [,3] #[1,] FALSE FALSE FALSE #[2,] TRUE FALSE TRUE A.K.
----- Original Message ----- From: Asis Hallab <asis.hal...@gmail.com> To: r-help@r-project.org Cc: Sent: Tuesday, December 4, 2012 4:16 PM Subject: [R] How to find matching columns in a matrix of lists? Dear R users, I have a matrix composed of lists: m <- matrix( list(), nrow=1, ncol=3 ) m[[ 1, 1 ]] <- list("A", "B") m[[ 1, 2 ]] <- list("A", "C") m[[ 1, 3 ]] <- list("A", "B") and want to get the sub-matrix where cells contain "B". But m[ , "B" %in% m[ 1, ], drop=F ] as well as m[ , "B" %in% m[ 1, ][], drop=F ] return empty matrices. Any ideas, hints and help will be very much appreciated! Kind regards! Josef [[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. ______________________________________________ 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.