-1

I have a dataset (already scaled) consisting of a total of 8 columns:

  • first column indicating the assigned cluster each observation belongs,
  • and, 7 dependent variables (each in a different column).

I would like to develop a Clustering Visualization through a Coordinate Plot in R, just like shown in the following blog (http://blog.datascienceheroes.com/short-lesson-on-cluster-analysis/).

Could anyone help me with this?

dsilvat
  • 9
  • 4

2 Answers2

1

Many options. You could do

library(GGally)
ggparcoord(aggregate(mtcars, list(as.factor(cutree(hclust(dist(mtcars)), k = 4))), mean), columns=-1, groupColumn=1)

or

library(parcoords)
parcoords(
  aggregate(mtcars, list(cutree(hclust(dist(mtcars)), k = 4)), mean),
  color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "Group.1")
)
parcoords(
  transform(mtcars, cluster = cutree(hclust(dist(mtcars)), k = 4)),
  color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "cluster")
)
lukeA
  • 53,097
  • 5
  • 97
  • 100
0

You have the code for the function you need(plot_clus_coord) here.

Pablo Casas
  • 868
  • 13
  • 15