Skip to content
Prev 139424 / 398503 Next

fast way to compare two matrices of combinations

On Thu, 13 Mar 2008, Mark W Kimpel wrote:

            
First, be sure that your code does what you really intend for it to do.

Does this really do what you wanted?

       if (length(intersect(triplets[,m], all.triplets[,k] == M))){

If so, then why does the first line below never produce an error?

 	 count.vec <- count.vec[,-redundant.vec]

 	is.null(dim(count.vec)) ## TRUE

You are basically tabulating. Use the functions that are built for that.

It looks like what you want is along these lines:

 	tab.combns <- function(x) apply( combn( sort(x), M ),2,
         	                        function(x) paste(x,collapse=''))

 	tab.all <- table( unlist( lapply(sig.tf.pairs,tab.combns) ) )

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901