# TODO: Add comment
# 
# Author: E.Korsching  11-2024
###############################################################################



## adjust the standard intersect(){base} function
#  to work on data.frames and matrices


intersect.e <- function(x, y){
	# wrapper for intersect()
	# intersection on matrices and data.frames with row.names()
	x.rn <- dimnames(x)[[1]]
	y.rn <- dimnames(y)[[1]]
	isec <- intersect(x=x.rn, y=y.rn)
	xs <- x[!(x.rn%in%isec),,drop=F]
	ys <- y[!(y.rn%in%isec),,drop=F]
	xy <- x[isec,,drop=F]
	return(list(xs=xs,xy=xy,ys=ys))
}


#a8 <- matrix(1:9,3,3); dimnames(a8)[[1]] <- c("a","b","c"); a9 <- matrix(10:18,3,3); dimnames(a9)[[1]] <- c("a","d","c")
#intersect.e(x=a8,y=a9)



