Demo entry 2375705

simple R

   

Submitted by anonymous on Aug 16, 2015 at 15:41
Language: S. Code size: 164 Bytes.

df <- iris
m <- as.matrix(cbind(df$Petal.Length, df$Petal.Width),ncol=2)
cl <- kmeans(m,3)
df$cluster <- factor(cl$cluster)
centers <- as.data.frame(cl$centers)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).