#CLUSTERING WOMEN ACCORDING TO THEIR SHAPE:
landmarks1 <- na.exclude(landmarks)
dim(landmarks1)
#[1] 574 198
(num.points <- (dim(landmarks1)[2]) / 3)
#[1] 66
landmarks2 <- landmarks1[1:50,] #In the interests of simplicity of the computation involved.
(n <- dim(landmarks2)[1])
#[1] 100
dg <- array(0,dim = c(num.points,3,n))
for(k in 1:n){
for(l in 1:3){
dg[,l,k] <- as.matrix(as.vector(landmarks2[k,][seq(l,
dim(landmarks2)[2]+(l-1),by=3)]),ncol=1,byrow=T)
}
}
Nclusters <- 3 ; Nsteps <- 5 ; niter <- 5 ; stopCr <- 0.0001
resLL <- LloydShapes(dg,Nclusters,Nsteps,niter,stopCr,FALSE,TRUE)
copt <- resLL$copt
shapes3dMod(copt[,,1], loop = 0, type = "p", color = 2, joinline = c(1:1),
axes3 = TRUE, rglopen = TRUE, main = "Mean shape cluster 1")
Run the code above in your browser using DataLab