Learn R Programming

kml3d (version 0.7)

as.clusterLongData: ~ Function: as.clusterizLongData (or as.cld) ~

Description

as.clusterizLongData (or as.cld) turns a data.frame, an array or a LongData into an object of class ClusterLongData.

Usage

## S3 method for class 'data.frame':
as.clusterLongData(data,idAll,time,timeDataFrame,varNames,maxNA=length(time)-2,criterionActif="calinski")
## S3 method for class 'data.frame':
as.cld(data,idAll,time,timeDataFrame,varNames,maxNA=length(time)-2,criterionActif="calinski")

## S3 method for class 'array':
as.clusterLongData(data,idAll,time,varNames,maxNA=length(time)-2,criterionActif="calinski")
## S3 method for class 'array':
as.cld(data,idAll,time,varNames,maxNA=length(time)-2,criterionActif="calinski")

## S3 method for class 'LongData':
as.clusterLongData(data,criterionActif="calinski")
## S3 method for class 'LongData':
as.cld(data,criterionActif="calinski")

Arguments

data
[data.frame], [array] or [LongData]: structure containning the longitudinal data. If data is a matrix or a data.frame, it should coutai
idAll
[vector(character)]: single identifier for each trajectory (ie each individual). For a data.frame, the default idAll is the first column ; For an array, the default idAll is the ve
varNames
[vector(numeric)]: names of the variable. For a data.frame, the default value is the names of the list provide to timeDataFrame. For an array, the default value is c(V1,V2,V3,...].
time
[vector(numeric)]: column number in which longitudinal data can be found. For a data.frame, the default value is the length of the first argument of timeDataFrame. For an array, the default val
timeDataFrame
[list(character=numeric,...)]: (for data.frame only) For each variable, timeDataFrame provide the column numbers that contain the trajectories. See example for details.
maxNA
[numeric] or [vector(numeric)]: Define, for each variable, the maximum number of missing values that a trajectories shall contain. Individual whose trajectory contains more missing value than maxNA are
criterionActif
[character]: criterion name that will be used by fonctions that need a single criterion (like plot or ordered).

Value

  • An object of class ClusterLongData.

Author(s)

Christophe Genolini INSERM U669 / PSIGIAM: Paris Sud Innovation Group in Adolescent Mental Health Modal'X / Universite Paris Ouest-Nanterre- La Defense Contact author : genolini@u-paris10.fr

Details

as.clusterizLongData (or as.cld) turns a data.frame into an object of class ClusterLongData according to its arguments.

References

Article "KmL: K-means for Longitudinal Data", in Computational Statistics, Volume 25, Issue 2 (2010), Page 317. Web site: http://christophe.genolini.free.fr/kml

Examples

Run this code
#################
### data.frame
myDataFrame <- data.frame(id=1:10,V1=rnorm(10),C1=rpois(10,1),V2=rnorm(10,1),C1=rpois(10,2),V3=rnorm(10,2),C2=rpois(10,2))
as.cld(myDataFrame,timeDataFrame=list(V1=c(2,4,6),v2=c(3,5,7)))

### Some time can be missing (like V12 in the following):
myDataFrame2 <- data.frame(id=11:12,Va11=c(1,4),Pe11=c(2,5),Pe12=c(3,5),Va13=c(2,3),Pe13=c(1,3))
as.cld(myDataFrame2,time=c(11,12,13),timeDataFrame=list(Va=c(2,NA,5),Pe=c(3,4,6)))


#################
### array
myArray <- array(rnorm(40),dim=c(5,4,2))
as.cld(myArray)
as.cld(myArray,idAll=c("I142","I156","I173","I181a","I181b"),time=c(6,12,24,48),varNames=c("Var1","Var2"),maxNA=0,criterionActif="ray")


#################
### LongData
myLongData <- as.longData(myArray)
as.cld(myLongData)

Run the code above in your browser using DataLab