[R] K mean clustering with extra constraints

Tsai Rainbow rainbowafmb at gmail.com
Thu Mar 24 19:08:51 CET 2016


Hi, I am a new R user. I have seen the use of kmeans in clustering.
However, I would like to ask how I can add more constraints to the kmeans.
For example, I have a set of data for a 10 nodes network,

price = c(84, 96, 57, 53, 90, 94, 81, 66, 93, 54)

I want to use K mean to to group this set of data into two group. However,
nodes in the same group should be in the same group. they are connected as
below.

 mymatrix <- rbind(
+      c(1,1,2,3,3,3,2,1,1,1),
+      c(1,1,1,2,2,2,1,1,1,1),
+      c(2,1,1,1,1,1,1,1,2,2),
+      c(3,2,1,1,1,1,1,2,3,3),
+      c(3,2,1,1,1,1,1,2,3,3),
+      c(3,2,1,1,1,1,1,2,2,2),
+      c(2,1,1,1,1,1,1,1,2,2),
+      c(1,1,1,2,2,2,1,1,1,1),
+      c(1,1,2,3,3,2,2,1,1,1),
+      c(1,1,2,3,3,2,2,1,1,1))

How can I do it in R. I greatly appreciate your help. I wish a happy
Easter.

Hanna

	[[alternative HTML version deleted]]



More information about the R-help mailing list