cccd <- function(x=NULL,y=NULL,dxx=NULL,dyx=NULL,method=NULL) { if(is.null(dxx) | is.null(dyx)){ if(is.null(x) | is.null(y)) stop("either x,y or dxx,dyx must be given") dyx <- as.matrix(dist(y,x,method=method)) dxx <- as.matrix(dist(x,method=method)) } R <- apply(dyx,2,min) M <- matrix(as.integer(dxx