R/calcDistance.R

Defines functions calcDistance

Documented in calcDistance

calcDistance <-
function(x, y, type="", method="hamming"){
	if(missing(x) || missing(y))
		stop("x and/or y is missing.")
	
	if(tolower(method) == "hamming"){
		ret <- sum(as.logical(unlist(x)) != as.logical(unlist(y)))
		
		if(tolower(type) == "adjmatrix" || tolower(type) == "m") #Divide by 2 because of duplicates
			ret <- ret / 2
	}else{
		stop(sprintf("%s is unknown.", as.character(method)))
	}
	
	return(ret)
}

Try the bingat package in your browser

Any scripts or data that you put into this service are public.

bingat documentation built on May 1, 2019, 9:11 p.m.