Constructs tours of data space based on centers of clusters

kmeansPath(data, length = 10, reorder = TRUE, conditionvars = NULL, ...)

pamPath(
  data,
  length = 10,
  reorder = TRUE,
  conditionvars = NULL,
  maxn = 4000,
  ...
)

claraPath(data, length = 10, reorder = TRUE, conditionvars = NULL, ...)

medoidPath(data, cl, reorder = FALSE)

centroidPath(data, cl, reorder = FALSE)

Arguments

data

A dataframe

length

Path length, defaults to 10

reorder

If TRUE uses DendSer to reorder the path dser

conditionvars

A vector of variable names. The returned tour is for this subset of variables.

...

ignored

maxn

(pamPath only) For datasets with more than maxn rows, use maxn randomly selected rows.

cl

A vector specifying cluster membership for rows of data.

Value

A dataframe with the path

Functions

  • kmeansPath(): Constructs a tour of data space following length k-means centroids

  • pamPath(): Constructs a tour of data space following length pam medoids

  • claraPath(): Constructs a tour of data space following length clara medoids

  • medoidPath(): Returns a path visiting cluster medoids

  • centroidPath(): Returns a path visiting cluster centroids

Examples

kmeansPath(mtcars,length=4)
#>        mpg      cyl     disp        hp     drat       wt     qsec           vs
#> 3 24.82000 4.533333 120.7800  91.66667 4.028000 2.501200 18.74600 8.000000e-01
#> 4 17.44444 7.555556 299.1556 156.11111 3.021111 3.610556 17.87778 2.222222e-01
#> 2 12.62000 8.000000 416.4000 228.00000 3.220000 4.685800 16.89400 5.551115e-17
#> 1 16.83333 7.333333 265.6667 258.00000 3.793333 3.170000 14.86667 0.000000e+00
#>              am     gear     carb
#> 3  6.666667e-01 4.066667 2.200000
#> 4  0.000000e+00 3.000000 2.111111
#> 2 -5.551115e-17 3.000000 4.000000
#> 1  1.000000e+00 5.000000 6.000000
pamPath(mtcars,length=4)
#>                      mpg cyl  disp  hp drat    wt  qsec vs am gear carb
#> Fiat X1-9           27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
#> Mazda RX4 Wag       21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
#> Merc 450SL          17.3   8 275.8 180 3.07 3.730 17.60  0  0    3    3
#> Lincoln Continental 10.4   8 460.0 215 3.00 5.424 17.82  0  0    3    4
claraPath(mtcars,length=4)
#>                      mpg cyl  disp  hp drat    wt  qsec vs am gear carb
#> Fiat X1-9           27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
#> Mazda RX4 Wag       21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
#> Merc 450SL          17.3   8 275.8 180 3.07 3.730 17.60  0  0    3    3
#> Lincoln Continental 10.4   8 460.0 215 3.00 5.424 17.82  0  0    3    4
medoidPath(mtcars,cl=rep(1:3, length.out=nrow(mtcars)))
#>                mpg cyl  disp  hp drat   wt  qsec vs am gear carb
#> Mazda RX4     17.3   8 275.8 180 3.07 3.73 17.60  0  0    3    3
#> Mazda RX4 Wag 17.8   6 167.6 123 3.92 3.44 18.90  1  0    4    4
#> Datsun 710    22.8   4 108.0  93 3.85 2.32 18.61  1  1    4    1