Learn R Programming

longitudinalData (version 2.4.7)

plot3dPdf: ~ Function: plot3dPdf for LongData ~

Description

Given a LongData and a Partition, this function create 'Triangle objects' representing the 3D plot the clusters centers. Triangle object can latter be used to include dynamic rotating graph in a pdf file.

Usage

# S4 method for LongData3d,missing
plot3dPdf(x,y,varY=1,varZ=2)
# S4 method for LongData3d,numeric
plot3dPdf(x,y,varY=1,varZ=2)

Value

A Triangle object.

Arguments

x

[LongData]: Object containing the trajectories to plot.

y

[numeric]: Partition that will be use to plot the object.

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.

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

Create Triangle objects representing the 3D plot of the main trajectories of a LongData.

The three functions plot3dPdf, saveTrianglesAsASY and makeLatexFile are design to export a 3D graph to a Pdf file. The process is the following:

  1. plot3dPdf: Create a scene, that is a collection of Triangle object that represent a 3D images.

  2. saveTrianglesAsASY: Export the scene in an '.asy' file.

  3. '.asy' can not be include in LaTeX file. LaTeX can read only '.pre' file. So the next step is to use the software asymptote to convert '.asy' to '.pre'. This is done by the command asy -inlineimage -tex pdflatex scene.asy (not in R, in a console).

  4. The previous step did produce a file scene+0.prc that can be include in a LaTeX file. makeLatexFile create a LaTeX file that is directly compilable (using pdfLatex). It produce a pdf file that contain the 3D object.

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

saveTrianglesAsASY,makeLatexFile,makeTriangles

Examples

Run this code
  ### Move to tempdir
  wd <- getwd()
  setwd(tempdir()); getwd()
  
  ### Generating the data
  data(artificialJointLongData)
  myLd <- longData3d(artificialJointLongData,timeInData=list(var1=2:12,var2=13:23))
  part <- partition(rep(1:3,each=50))
  plotTrajMeans3d(myLd,part)

  ### Creation of the scene
  scene <- plot3dPdf(myLd,part)
  drawScene.rgl(scene)

  ### Export in '.asy' file
  saveTrianglesAsASY(scene)

  ### Creation of a '.prc' file
  # Open a console, then run:
  # 'asy -inlineimage -tex pdflatex scene.asy'

  ### Creation of the LaTeX main document
  makeLatexFile()

  ### Creation of the '.pdf'
  # Open a console window, then run
  # pdfLatex main.tex
  
  ### Go back to current dir
  setwd(wd)

Run the code above in your browser using DataLab