Type: Package
Title: Hierarchical Cluster Analysis (Learning Didactically)
Version: 0.1.0
Description: Implements hierarchical clustering methods (single linkage, complete linkage, average linkage, and centroid linkage) with stepwise printing and dendrograms for didactic purposes.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-09-18 14:57:50 UTC; gsaga
Author: Gualberto Segundo Agamez Montalvo [aut, cre]
Maintainer: Gualberto Segundo Agamez Montalvo <gsagamez@dema.ufc.br>
Repository: CRAN
Date/Publication: 2025-09-23 10:30:02 UTC

Hierarchical Clustering - Average linkage

Description

A function that performs hierarchical clustering with average linkage. It can also print the clustering steps and display a dendrogram

Usage

hclust_average(
  data,
  metric = "euclidean",
  print.steps = TRUE,
  plot = TRUE,
  label.names = TRUE
)

Arguments

data

Numerical matrix or data frame of observations (rows = observations, columns = variables).

metric

Distance metric to be used (default: "euclidean").

print.steps

If TRUE, the algorithm's steps are printed.

plot

If TRUE, a dendrogram is plotted.

label.names

If TRUE, uses the row names as labels in the dendrogram.

Value

object of class "hclust".

Examples

y1 <- c(1, 2, 1, 0); y2 <- c(2, 1, 0, 2)
y3 <- c(8, 8, 9, 7); y4 <- c(6, 9, 8, 9)
Data <- rbind(y1, y2, y3, y4)
hc <- hclust_average(Data, metric = "euclidean",
                     print.steps = TRUE,
                     plot = TRUE,
                     label.names = TRUE)

Hierarchical Clustering - Centroid

Description

A function that performs hierarchical clustering with centroid linkage. It can also print the clustering steps and display a dendrogram

Usage

hclust_centroid(
  data,
  metric = "euclidean",
  print.steps = TRUE,
  plot = TRUE,
  label.names = TRUE
)

Arguments

data

Numerical matrix or data frame of observations (rows = observations, columns = variables).

metric

Distance metric to be used (default: "euclidean").

print.steps

If TRUE, the algorithm's steps are printed.

plot

If TRUE, a dendrogram is plotted.

label.names

If TRUE, uses the row names as labels in the dendrogram.

Value

object of class "hclust".

Examples

y1 <- c(1, 2, 1, 0); y2 <- c(2, 1, 0, 2)
y3 <- c(8, 8, 9, 7); y4 <- c(6, 9, 8, 9)
Data <- rbind(y1, y2, y3, y4)
hc <- hclust_centroid(Data, metric = "euclidean",
                      print.steps = TRUE,
                      plot = TRUE,
                      label.names = TRUE)

Hierarchical Clustering - Complete linkage

Description

A function that performs hierarchical clustering with complete linkage. It can also print the clustering steps and display a dendrogram

Usage

hclust_complete(
  data,
  metric = "euclidean",
  print.steps = TRUE,
  plot = TRUE,
  label.names = TRUE
)

Arguments

data

Numerical matrix or data frame of observations (rows = observations, columns = variables).

metric

Distance metric to be used (default: "euclidean").

print.steps

If TRUE, the algorithm's steps are printed.

plot

If TRUE, a dendrogram is plotted.

label.names

If TRUE, uses the row names as labels in the dendrogram.

Value

object of class "hclust".

Examples

y1 <- c(1, 2, 1, 0); y2 <- c(2, 1, 0, 2)
y3 <- c(8, 8, 9, 7); y4 <- c(6, 9, 8, 9)
Data <- rbind(y1, y2, y3, y4)
hc <- hclust_complete(Data, metric = "euclidean",
                      print.steps = TRUE,
                      plot = TRUE,
                      label.names = TRUE)

Hierarchical Clustering - Single linkage

Description

A function that performs hierarchical clustering with single linkage. It can also print the clustering steps and display a dendrogram

Usage

hclust_single(
  data,
  metric = "euclidean",
  print.steps = TRUE,
  plot = TRUE,
  label.names = TRUE
)

Arguments

data

Numerical matrix or data frame of observations (rows = observations, columns = variables).

metric

Distance metric to be used (default: "euclidean").

print.steps

If TRUE, the algorithm's steps are printed.

plot

If TRUE, a dendrogram is plotted.

label.names

If TRUE, uses the row names as labels in the dendrogram.

Value

object of class "hclust".

Examples

y1 <- c(1, 2, 1, 0); y2 <- c(2, 1, 0, 2)
y3 <- c(8, 8, 9, 7); y4 <- c(6, 9, 8, 9)
Data <- rbind(y1, y2, y3, y4)
hc <- hclust_single(Data, metric = "euclidean",
                    print.steps = TRUE,
                    plot = TRUE,
                    label.names = TRUE)