Learn R Programming

longitudinalData (version 2.3)

plotTraj3d,LongData: ~ Function: plotTraj3d for LongData3d ~

Description

Plot two variables of a LongData3d object in 3D, optionnaly relatively to a Partition.

Usage

## S3 method for class 'LongData3d,missing':
plotTraj3d(x,y,varY=1,varZ=2,
   parTraj=parTRAJ(),parMean=parMEAN(),nbSample=1000,...)
## S3 method for class 'LongData3d,Partition':
plotTraj3d(x,y,varY=1,varZ=2,
   parTraj=parTRAJ(type="n"),parMean=parMEAN(),nbSample=1000,...)

Arguments

x
[LongData3d]: Object containing the trajectories to plot.
y
[Partition]: Partition that will be use to plot the object. If y is missing, a Partition with a single clusters is considered.
varY
[numeric] or [character]: either the number or the name of the first variable to display. 1 by default.
varZ
[numeric] or [character]: either the number or the name of the second variable to display. 2 by default.
parTraj
[parLongData]: Set the graphical parameters used to plot the trajectories of the LongData3d. See ParLongData and examples for details.
parMean
[parLongData]: Set the graphical parameters used to plot the mean trajectories of each clusters LongData3d (only when y is non missing). See ParLongData and exa
nbSample
[numeric]: Graphical display of huge sample can be time consumming. This parameters fixe the maximum numbre of trajectories (randomly chosen) that will be drawn.
...
Arguments to be passed to methods, such as graphical parameters.

Author

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

Details

Plot two variables of a LongData3d object in 3D. It use the rgl library. The user can make the graphical representation turn using the mouse.

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

LongData3d

Examples

Run this code
##################
### Construction of the data

time=c(1,2,3,4,8,12,16,20)
id2=1:120
f <- function(id,t)((id-1)%%3-1) * t
g <- function(id,t)(id%%2+1)*t
h <- function(id,t)(id%%4-0.5)*(20-t)
ld <- longData3d(array(cbind(outer(id2,time,f),outer(id2,time,g),outer(id2,time,h))+
   rnorm(120*8*3,0,3),dim=c(120,8,3)))
part <- partition(rep(1:6,20))

### Basic plotting
plotTraj3d(ld)
plotTraj3d(ld,part)

### Variable 1 and 3, then 2 and 3
plotTraj3d(ld,part)
plotTraj3d(ld,part,varY=3,varZ=2)
plotTraj3d(ld,part,varY=1,varZ=3)

##################
### Changing graphical parameters 'par'

### Color individual according to its clusters (col="clusters")
plotTraj3d(ld,part,parTraj=parTRAJ(col="clusters"))
plotTraj3d(ld,part,parTraj=parTRAJ(col="clusters"),varY=1,varZ=3)

### No mean trajectories (type="n"), only few trajectories
### Color individual according to its clusters (col="clusters")
plotTraj3d(ld,part,parTraj=parTRAJ(col="clusters"),parMean=parMEAN(type="n"),nbSample=10)

Run the code above in your browser using DataLab