Learn R Programming

kml (version 2.1.2)

trajKmlSlow: ~ Function:trajKmlSlow ~

Description

Ben

Usage

trajKmlSlow(traj, clusterAffectation, nbId = nrow(traj), nbTime = ncol(traj), maxIt = 200, screenPlot = NA, distance = function(x, y) dist(rbind(x, y)), centerMethod = meanNA, ...)

Arguments

traj
clusterAffectation
nbId
nbTime
maxIt
screenPlot
distance
centerMethod
...

Value

  • aze

Details

aze

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(traj,clusterAffectation,nbId=nrow(traj),nbTime=ncol(traj),maxIt=200,screenPlot=NA,
   distance=function(x,y)dist(rbind(x,y)),centerMethod=meanNA,...
){
#    if (distance \%in\% METHODS){distanceFun <- function(x,y){return(dist(t(cbind(x,y)),method=distance))}}else{distanceFun <- distance}
 #   print(distanceFun)
    exClusterAffectation <- partition()
    for(iterations in 1:maxIt){
        clustersCenter <- calculCenterGeneralized(traj=traj,xPart=clusterAffectation,centerMethod=centerMethod)
        clusterAffectation <- affectIndivGeneralized(traj=traj,clustersCenter=clustersCenter,distance=distance)
        if(identical(clusterAffectation,exClusterAffectation)){
            return(list(clusterAffectation=clusterAffectation,convergenceTime=iterations))
        }else{
            exClusterAffectation <- clusterAffectation
        }
        if(!is.na(screenPlot)){
            ld <- longData(traj=traj,id=1:nrow(traj),time=1:ncol(traj))
            screen(screenPlot)
            plot(ld,clusterAffectation,col="clusters",col.mean="clusters",main=paste("Iteration =",iterations),...)
        }else{}
    }
    return(list=c(clusterAffectation=clusterAffectation,convergenceTime=Inf))
  }

Run the code above in your browser using DataLab