| affectIndiv {kml} | R Documentation |
~ Functions: affectIndiv & affectIndivC ~
Description
Given some longitudinal data (trajectories) and k clusters' centers,
affectIndiv and affectIndivC
affect each individual to the cluster whose centre is the closest.
Usage
affectIndiv(traj, clustersCenter, distance = function(x,y){dist(rbind(x, y))})
affectIndivC(traj, clustersCenter)
Arguments
traj |
|
clustersCenter |
|
distance |
|
Details
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.
Value
Object of classPartition.
Examples
#######################
### 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))