Learn R Programming

hclustTeach (version 0.1.0)

hclust_average: 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
)

Value

object of class "hclust".

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab