- method <-"%s"
- mat <- simil(dm, method = method, diag = TRUE, upper = TRUE, by_rows = FALSE)
- """ % self.analyse.indices[self.parametres['coeff']]
- txt += """
- mat <- as.matrix(stats::as.dist(mat,diag=TRUE,upper=TRUE))
- mat[is.na(mat)] <- 0
- mat[is.infinite(mat)] <- 0
- """
+ mat <- as.matrix(stats::as.dist(mat,diag=TRUE,upper=TRUE))
+ mat[is.na(mat)] <- 0
+ if (length(which(mat == Inf))) {
+ infp <- which(mat == Inf)
+ mat[infp] <- NA
+ maxmat <- max(mat, na.rm = TRUE)
+ if (maxmat > 0) {
+ maxmat <- maxmat + 1
+ } else {
+ maxmat <- 0
+ }
+ mat[infp] <- maxmat
+ }
+ if (length(which(mat == -Inf))) {
+ infm <- which(mat == -Inf)
+ mat[infm] <- NA
+ minmat <- min(mat, na.rm = TRUE)
+ if (maxmat < 0) {
+ minmat <- minmat - 1
+ } else {
+ minmat <- 0
+ }
+ mat[infm] <- minmat
+ }
+ """
+ if 'word' in self.parametres and not self.parametres['keep_coord'] :
+ txt += """
+ mat <- graph.word(mat, index)
+ cs <- colSums(mat)
+ if (length(cs)) mat <- mat[,-which(cs==0)]
+ rs <- rowSums(mat)
+ if (length(rs)) mat <- mat[-which(rs==0),]
+ if (length(cs)) dm <- dm[, -which(cs==0)]
+ """
+