mosaic tools for clustering

# S3 method for hclust
fortify(
  model,
  data,
  which = c("segments", "heatmap", "leaves", "labels", "data"),
  k = 1,
  ...
)

# S3 method for hclust
mplot(
  object,
  data,
  colorize = TRUE,
  k = 1,
  labels = FALSE,
  heatmap = 0,
  enumerate = "white",
  ...
)

Arguments

model

a model

data

a data-like object

which

which kind of fortification to compute

k

number of clusters

...

additional arguments passed on to link{dendro_data}

object

an object of class "hclust"

colorize

whether to show clusters in different colors

labels

a logical indicating whether labels should be used to identify leaves of the tree.

heatmap

the ratio of size of heatmap to size of dendrogram. Use 0 or FALSE to omit the heatmap.

enumerate

a color used for numbers within heatmap. Use "transparent" to hide.

Examples

KidsFeet |> select(-name, -birthmonth) |> rescale() -> KidsFeet2
  M <- dist(KidsFeet2)
  Cl <- hclust(M)
  fortify(Cl, k=5) |> head(3)
#>          x        y    xend     yend order group
#> 1 17.64258 2.153880 6.03125 2.153880    34     4
#> 2  6.03125 2.153880 6.03125 1.833039    34     4
#> 3  6.03125 1.833039 2.68750 1.833039    35     4
  fortify(Cl, which="heatmap", data=KidsFeet2) |> head(3)
#>   idx position  variable value variable_num
#> 1   1       15 birthyear     1            1
#> 2   2       37 birthyear     0            1
#> 3   3       35 birthyear     0            1
  fortify(Cl, which="data", data=KidsFeet2) |> head(3)
#>   birthyear    length     width sex biggerfoot domhand idx position
#> 1         1 0.4745763 0.2631579   0          0       1   1       15
#> 2         0 0.6440678 0.4736842   0          0       0   2       37
#> 3         0 0.4915254 0.9473684   0          1       1   3       35
  fortify(Cl, which="labels") |> head(3)
#>   x y label order
#> 1 1 0     6     6
#> 2 2 0    21    21
#> 3 3 0    35    35
  mplot(Cl, data=KidsFeet2, k=4, heatmap=2)

  mplot(Cl, data=KidsFeet2, k=4, heatmap=0.5, enumerate="transparent")

  mplot(Cl, data=KidsFeet2, k=4, heatmap=2, type="triangle")

  mplot(Cl, data=KidsFeet2, k=4, heatmap=0, type="triangle")