code seems OK; still wavelets test to write
[epclust.git] / epclust / tests / testthat / helper.computeMedoidsIndices.R
CommitLineData
d9bb53c5
BA
1# R-equivalent of computeMedoidsIndices, requiring a matrix
2# (thus potentially breaking "fit-in-memory" hope)
0486fbad
BA
3R_computeMedoidsIndices <- function(medoids, series)
4{
d9bb53c5
BA
5 nb_series = ncol(series) #series in columns
6
0486fbad
BA
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 ) )
d9bb53c5 10
0486fbad
BA
11 mi
12}