Translate clusternum
This commit is contained in:
parent
838805877e
commit
02b20f50a9
1 changed files with 16 additions and 0 deletions
16
R/clusternum.R
Normal file
16
R/clusternum.R
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
clusternum <- function(X, T, k, c) {
|
||||
m <- size(X, 1) + 1
|
||||
while (!is.null(k)) {
|
||||
# % Get the children of nodes at this level
|
||||
children <- X[k, 1:2]
|
||||
children <- children[, ]
|
||||
|
||||
# % Assign this node number to leaf children
|
||||
t <- (children <= m)
|
||||
T[children(t)] <- c
|
||||
|
||||
# % Move to next level
|
||||
k <- children(!t) - m
|
||||
}
|
||||
return(T)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue