[R] Test for column equality across matrices

William Dunlap wdunlap at tibco.com
Sat Jul 13 19:30:11 CEST 2013


Try
   columnsOf <- function(mat) split(mat, col(mat))
   newB <- B[ , !is.element(columnsOf(B), columnsOf(A))]

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Thiem Alrik
> Sent: Saturday, July 13, 2013 6:45 AM
> To: mailman, r-help
> Subject: [R] Test for column equality across matrices
> 
> Dear list,
> 
> I have two matrices
> 
> A <- matrix(t(expand.grid(c(1,2,3,4,5), 15, 16)), nrow = 3)
> B <- combn(16, 3)
> 
> Now I would like to exclude all columns from the 560 columns in B which are identical to
> any 1 of the 6 columns in A. How could I do this?
> 
> Many thanks and best wishes,
> 
> Alrik
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list