+dist.labbe2 <- function(tab) {
+ distance_from_idxs <- function (idxs) {
+ i1 <- idxs[1]
+ i2 <- idxs[2]
+ compute.labbe(i1, i2, tab)$indice.labbe
+ }
+
+ size <- ncol(tab)
+ d <- apply(utils::combn(size, 2), 2, distance_from_idxs)
+ attr(d, "Size") <- size
+ xnames <- colnames(tab)
+ if (!is.null(xnames)) {
+ attr(d, "Labels") <- xnames
+ }
+ attr(d, "Diag") <- FALSE
+ attr(d, "Upper") <- FALSE
+ class(d) <- "dist"
+ d
+ #mat <- matrix(NA, ncol=ncol(tab), nrow=ncol(tab))
+ #rownames(mat) <- colnames(tab)
+ #colnames(mat) <- colnames(tab)
+ #for (i in 1:(ncol(tab)-1)) {
+ # for (j in (1+i):ncol(tab)) {
+ #lab <- compute.labbe(i,j,tab)
+ # mat[j,i] <- compute.labbe(i,j,tab)$indice.labbe
+ # }
+ #}
+ #mat
+}
+
+dist.labbe3 <- function(tab) {
+ distance_from_idxs <- function (idxs) {
+ i1 <- tab[,idxs[1]]
+ i2 <- tab[,idxs[2]]
+ labbe(i1, i2)
+ }
+
+ size <- ncol(tab)
+ d <- apply(utils::combn(size, 2), 2, distance_from_idxs)
+ attr(d, "Size") <- size
+ xnames <- colnames(tab)
+ if (!is.null(xnames)) {
+ attr(d, "Labels") <- xnames
+ }
+ attr(d, "Diag") <- FALSE
+ attr(d, "Upper") <- FALSE
+ class(d) <- "dist"
+ d
+
+}