clusterLongData3d {kml3d}R Documentation

~ Function: clusterLongData3d (or cld3d) ~

Description

clusterLongData3d (or cld3d in short) is the constructor for ClusterLongData3d object.

Usage

clusterLongData3d(traj, idAll, time, timeInData, varNames, maxNA)
cld3d(traj, idAll, time, timeInData, varNames, maxNA)

Arguments

traj

[array(numeric)] or [data.frame]: structure containning the joint-trajectories. Each line (traj[i,,]) is a joint-trajectory of an individual ; columns (traj[,j,]) refer to the time during which measures were made ; the third dimensions (traj[,,l]) are for variables.

idAll

[vector(character)]: single identifier for each trajectory (ie each individual). Note that the identifiers are of type character (that allow to deal identifiers like XUK32-612, identifiers that our favorite epidemiologists are so good at providing). If idAll are numeric, they are converted into characters.

time

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

timeInData

[list(vector(numeric))]: precise the column containing the trajectories. The list labels are the names of the variables (like list(A=c(2,3,4),B=c(5,7,9))).

varNames

[character]: name of the variable being measured.

maxNA

[numeric] or [vector(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. Note the maxNA can take diffents values for each variable-trajectories. The default value is length(time)-2.

Details

clusterLongData3d construct a object of class ClusterLongData. Two cases can be distinguised:

traj is an array:

the first dimension (line) are individual. The second dimension (column) are time at which the measurement are made. The third dimension are the differents variable-trajectories. For example, traj[,,2] is the second variable-trajectory.

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

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

If traj is a data.frame:

lines are individual. Time of measurement and variables should be provide through timeInData. timeInData is a list. The label of the list are the variable-trajectories names. Elements of the list are the column containning the trajectories. For example, if timeInData=list(V=c(2,3,4),W=c(6,8,12)), then the first variable-trajectory is 'V', its mesearment are in column 2,3 and 4. The second variable-trajectory is 'W', its measurment are in column 6,8 and 12.

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

Value

An object of class ClusterLongData3d.

Examples

###############
### Building an array
tr1n <- array(c(1,2,NA, 1,4,NA, 6,1,8, 10,NA,2, 3,NA,NA,
                4,NA,5,  6,3,4, 3,4,4, 4,NA,NA, 5,5,4),
            dim=c(3,5,2))


###############
### clusterLongData

### With maxNA=3
clusterLongData3d(traj=tr1n,
    idAll=as.character(c(100,102,104)),
    time=c(1,2,4,8,16),
    varNames=c("P","A"),
    maxNA=3
)

### With maxNA=2
### Individual 104 is exclude
clusterLongData3d(traj=tr1n,
    idAll=as.character(c(100,102,104)),
    time=c(1,2,4,8,16),
    varNames=c("P","A"),
    maxNA=2
)


[Package kml3d version 2.4.6.1 Index]