# Synthetic problem: 10 random seeds with coordinates in [0..20]
# to which random values in [-0.1..0.1] are added
M<-matrix(0,100,500)
rownames(M)<-paste0("rn",c(1:100))
for (i in (1:10))
{
p<-20*runif(500)
Rf <- matrix(0.2*(runif(5000)-0.5),nrow=10)
for (k in (1:10))
{
M[10*(i-1)+k,]=p+Rf[k,]
}
}
JWriteBin(M,"pamtest.bin",dtype="float",dmtype="full")
CalcAndWriteDissimilarityMatrix("pamtest.bin","pamDL2.bin",distype="L2",restype="float",nthreads=0)
L <- ApplyPAM("pamDL2.bin",10,init_method="BUILD")
df <- ClassifAsDataFrame(L,"pamDL2.bin")
df
# Identification of medoids:
which(df[,3]==0)
# Verification they are the same as in L (in different order)
L$med
file.remove("pamtest.bin")
file.remove("pamDL2.bin")
Run the code above in your browser using DataLab