cccd <- function(x=NULL,y=NULL,dxx=NULL,dyx=NULL,p=2,d=2) { if(is.null(dxx) | is.null(dyx)){ if(is.null(x) | is.null(y)) stop("either x,y or dxx,dyx must be given") if(missing(d)){ if(is.matrix(x)){ d <- ncol(x) } else if(is.matrix(y)){ d <- ncol(y) } else d <- 1 } dyx <- pdist(y,x,p=p,d=d) dxx <- pdist(x,p=p,d=d) } R <- apply(dyx,2,min) M <- matrix(as.integer(dxx