| affectIndiv | R Documentation |
Given some longitudinal data (trajectories) and k clusters' centers,
affectIndiv and affectIndivC
affect each individual to the cluster whose centre is the closest.
affectIndiv(traj, clustersCenter, distance = function(x,y){dist(rbind(x, y))})
affectIndivC(traj, clustersCenter)
traj |
|
clustersCenter |
|
distance |
|
Given a matrix of clusters center clustersCenter (each line is
a cluster center), the function affectIndiv affect each
individual of the matrix traj to the closest clusters
(according to distance). affectIndivC does the same but
assume that the distance is the Euclidean
distance. affectIndivC is writen in C (and is therefor much faster).
affectIndiv used with calculTrajMean simulates one k-means step.
Object of classPartition.
#######################
### affectIndiv
### Some trajectories
traj <- gald()["traj"]
### 4 clusters centers
center <- traj[runif(4,1,nrow(traj)),]
### Affectation of each individual
system.time(part <- affectIndiv(traj,center))
system.time(part <- affectIndivC(traj,center))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.