cd6a30e94a336f0fa18aadc388949e46f38bf63d
[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) #series in columns
6
7 mi = rep(NA,nb_series)
8 for (i in 1:nb_series)
9 mi[i] <- which.min( colSums( sweep(medoids, 1, series[,i], '-')^2 ) )
10
11 mi
12 }