longData: ~ Function: longData ~

View source: R/longData.r

longDataR Documentation

~ Function: longData ~

Description

longData is a constructor for the class LongData. It create object LongData containing a single variable-trajectory. For creating joint variable-trajectories, see longData3d.

Usage

longData(traj, idAll, time, timeInData,varNames,maxNA)

Arguments

traj

[matrix(numeric)], [array(numeric)] or [data.frame]: structure containning the trajectories.

idAll

[vector(character)]: single identifier for each trajectory (ie each individual).

time

[vector(numeric)]: time at which measures were made.

timeInData

[list(vector(numeric))]: precise the column containing the trajectories.

varNames

[character]: name of the variable-trajectory being measured.

maxNA

[numeric]: maximum number of NA that are tolerates on a trajectory. If a trajectory has more missing than maxNA, then it is remove from the analysis.

Details

longData construct a object of class LongData. Two cases can be distinguised:

traj is an array:

lines are individual. Column are time of measurment.

If idAll is missing, the individuals are labelled i1, i2, i3,...

If timeInData is missing, all the column are used (timeInData=1:ncol(traj)).

If traj is a data.frame:

lines are individual. Column are time of measurement.

If idAll is missing, then the first column of the data.frame is used for idAll

If timeInData is missing and idAll is missing, then all the columns but the first are used for timeInData (the first is omited since it is already used for idAll): idAll=traj[,1],timeInData=2:ncol(traj).

If timeInData is missing but idAll is not missing, then all the column including the first are used for timeInData: timeInData=1:ncol(traj).

Value

An object of class LongData.

Author

Christophe Genolini
1. UMR U1027, INSERM, Universit<e9> Paul Sabatier / Toulouse III / France
2. CeRSME, EA 2931, UFR STAPS, Universit<e9> de Paris Ouest-Nanterre-La D<e9>fense / Nanterre / France

References

[1] C. Genolini and B. Falissard
"KmL: k-means for longitudinal data"
Computational Statistics, vol 25(2), pp 317-328, 2010

[2] C. Genolini and B. Falissard
"KmL: A package to cluster longitudinal data"
Computer Methods and Programs in Biomedicine, 104, pp e112-121, 2011

See Also

LongData

Examples

#####################
### From matrix

### Small data
mat <- matrix(c(1,NA,3,2,3,6,1,8,10),3,3,dimnames=list(c(101,102,104),c("T2","T4","T8")))
longData(mat)
(ld1 <- longData(traj=mat,idAll=as.character(c(101,102,104)),time=c(2,4,8),varNames="V"))
plotTrajMeans(ld1)

### Big data
mat <- matrix(runif(1051*325),1051,325)
(ld2 <- longData(traj=mat,idAll=paste("I-",1:1051,sep=""),time=(1:325)+0.5,varNames="Random"))

####################
### From data.frame

dn <- data.frame(id=1:3,v1=c(NA,2,1),v2=c(NA,1,0),v3=c(3,2,2),v4=c(4,2,NA))

### Basic
longData(dn)

### Selecting some times
(ld3 <- longData(dn,timeInData=c(1,2,4),varNames=c("Hyp")))

### Excluding trajectories with more than 1 NA
(ld3 <- longData(dn,maxNA=1))

longitudinalData documentation built on Feb. 16, 2023, 9:54 p.m.