Updated functions_migration.R with R version of kmeans (preferred)

Use kmeans in the stat package - seems like a better alternative to the c code (but the c code is left in).