9342feb2b06f6ba44d2c43d12c1bf8979df6ed28
[epclust.git] / epclust / tests / testthat / helper.computeMedoidsIndices.R
1 #R-equivalent of computeMedoidsIndices, requiring a matrix
2 #(thus potentially breaking "fit-in-memory" hope)
3 R_computeMedoidsIndices <- function(medoids, series)
4 {
5 nb_series = ncol(series)
6 mi = rep(NA,nb_series)
7 for (i in 1:nb_series)
8 mi[i] <- which.min( colSums( sweep(medoids, 1, series[,i], '-')^2 ) )
9 mi
10 }