Search notes:

R function: kmeans

#
#  Compare with ../libraries/fpc/pamk.R
#
x11()

set.seed(280870)

df <- data.frame (
      x = runif(30, 0, 20),
      y = runif(30, 0, 20)
)

km <- kmeans(df, 3)
plot(df, col=km$cluster, pch=19)
points(km$centers, col=1:3, pch=8, cex=2) # Show center of clusters
z <- locator(1)

km <- kmeans(df, 4)
plot(df, col=km$cluster, pch=19)
points(km$centers, col=1:4, pch=8, cex=2)
z <- locator(1)

km <- kmeans(df, 5)
plot(df, col=km$cluster, pch=19)
points(km$centers, col=1:5, pch=8, cex=2)
z <- locator(1)
Github repository about-r, path: /functions/kmeans.R

See also

Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201148, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/kmeans(64): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78