From 4520fd30fb38dc91ea41370d3382f8d02e94d129 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Thu, 20 May 2021 09:18:05 +0200 Subject: [PATCH] Fixed syntax --- R/cluster_own.R | 4 ++-- R/clusternum.R | 16 +++++++--------- R/greedyMix.R | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/R/cluster_own.R b/R/cluster_own.R index 306fbbf..12d4fbf 100644 --- a/R/cluster_own.R +++ b/R/cluster_own.R @@ -13,7 +13,7 @@ cluster_own <- function(Z, nclust) { } else { clsnum <- 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 T[i] = clsnum clsnum = clsnum + 1 @@ -21,7 +21,7 @@ cluster_own <- function(Z, nclust) { T <- clusternum(Z, T, i - m, clsnum) clsnum <- clsnum + 1 } - i <- Z(k, 2) # right tree + i <- Z[k, 2] # right tree if (i <= m) { # original node, no leafs T[i] <- clsnum clsnum <- clsnum + 1 diff --git a/R/clusternum.R b/R/clusternum.R index dbdcdbb..9f9cd5f 100644 --- a/R/clusternum.R +++ b/R/clusternum.R @@ -1,16 +1,14 @@ clusternum <- function(X, T, k, c) { m <- size(X, 1) + 1 - while (!is.null(k)) { - # % Get the children of nodes at this level + while (!isempty(k)) { + # Get the children of nodes at this level 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(t)] <- c - - # % Move to next level - k <- children(!t) - m + T[children[t]] <- c + # Move to next level + k <- children[!t] - m } return(T) -} +} \ No newline at end of file diff --git a/R/greedyMix.R b/R/greedyMix.R index 4ff05cf..e3ef7a3 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -77,10 +77,10 @@ greedyMix <- function( # h0 = findobj('Tag','filename1_text'); # set(h0,'String',filename); clear h0; message( - 'When using data which are in BAPS-format,', - 'you can specify the sampling populations of the', - 'individuals by giving two additional files:', - 'one containing the names of the populations,', + 'When using data which are in BAPS-format, ', + 'you can specify the sampling populations of the ', + 'individuals by giving two additional files: ', + 'one containing the names of the populations, ', 'the other containing the indices of the first ', 'individuals of the populations.' )