Fixed syntax

This commit is contained in:
Waldir Leoncio 2021-05-20 09:18:05 +02:00
parent 8eb81c51d2
commit 4520fd30fb
3 changed files with 13 additions and 15 deletions

View file

@ -13,7 +13,7 @@ cluster_own <- function(Z, nclust) {
} else { } else {
clsnum <- 1 clsnum <- 1
for (k in (m - maxclust + 1):(m - 1)) { for (k in (m - maxclust + 1):(m - 1)) {
i = Z(k, 1) # left tree i = Z[k, 1] # left tree
if (i <= m) { # original node, no leafs if (i <= m) { # original node, no leafs
T[i] = clsnum T[i] = clsnum
clsnum = clsnum + 1 clsnum = clsnum + 1
@ -21,7 +21,7 @@ cluster_own <- function(Z, nclust) {
T <- clusternum(Z, T, i - m, clsnum) T <- clusternum(Z, T, i - m, clsnum)
clsnum <- clsnum + 1 clsnum <- clsnum + 1
} }
i <- Z(k, 2) # right tree i <- Z[k, 2] # right tree
if (i <= m) { # original node, no leafs if (i <= m) { # original node, no leafs
T[i] <- clsnum T[i] <- clsnum
clsnum <- clsnum + 1 clsnum <- clsnum + 1

View file

@ -1,16 +1,14 @@
clusternum <- function(X, T, k, c) { clusternum <- function(X, T, k, c) {
m <- size(X, 1) + 1 m <- size(X, 1) + 1
while (!is.null(k)) { while (!isempty(k)) {
# % Get the children of nodes at this level # Get the children of nodes at this level
children <- X[k, 1:2] children <- X[k, 1:2]
children <- children[, ]
# % Assign this node number to leaf children # Assign this node number to leaf children
t <- (children <= m) t <- (children <= m)
T[children(t)] <- c T[children[t]] <- c
# Move to next level
# % Move to next level k <- children[!t] - m
k <- children(!t) - m
} }
return(T) return(T)
} }