Basic functions for drawing path diagrams

Implementation of simple functions to draw basic path diagrams just for visualization purposes.


pathdiagram provides simple functions to draw basic PLS path diagrams in R, just for illustrating purposes (i.e. adding diagrams when writing reports with knitr or Sweave).

Motivation

The one and only reason to create pathdiagram was the need to plot a path diagram in R. Since I was writing the tutorials and demos for the package plspm I realized that I badly needed path diagrams accompanying my examples. I first tried using the grid package. It was fine but it didn't allow me to have complete control over the looking of the objects (mainly with color of lines, borders, text, etc). Then I tried to use the package diagram but I got the same restrictions. Finally, after some short experiments, I decided to create pathdiagram.

Installation

Stable version on CRAN

# stable version  
install.packages("pathdiagram")

Development version on github

# development version  
library(devtools)
install_github('pathdiagram',  username='gastonstat')

Some Examples

# graphic specifications of manifest variables 
ingredients = list(
  eggs = manifest("Eggs", x = 0.25, y = 0.8, width = 0.1, height = 0.08),
  milk = manifest("Milk", x = 0.25, y = 0.65, width = 0.1, height = 0.08),
  flour = manifest("Flour", x = 0.25, y = 0.5, width = 0.1, height = 0.08),
  sugar = manifest("Sugar", x = 0.25, y = 0.35, width = 0.1, height = 0.08),
  butter = manifest("Butter", x = 0.25, y = 0.2, width = 0.1, height = 0.08)
)
 
# graphic specifications of latent variables 
pancakes = latent("Pancakes", x = 0.8, y = 0.65, rx = 0.08, ry = 0.06)
waffles = latent("Waffles", x = 0.8, y = 0.35, rx = 0.08, ry = 0.06)
 
 
# open a new wall 
wall()
 
# draw latent variables 
draw(pancakes)
draw(waffles)
 
# draw ingredients 
for (in 1:5) { 
  draw(ingredients[[i]])
}
 
# add arrows 
for (in 1:5) { 
  arrow(from = ingredients[[i]], to = pancakes, start = "east", end = "west")
  arrow(from = ingredients[[i]], to = waffles, start = "east", end = "west")
}

Author Contact

www.gastonsanchez.com

Gaston Sanchez (gaston.stat at gmail.com)

News

Version 0.1.9 (2013-07-10)

  • add vignette

Version 0.1.8 (2012-11-08)

  • remove parameter mar from function wall (it wasn't that useful)

  • add parameter xpd to function wall

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("pathdiagram")

0.1.9 by Gaston Sanchez, 6 years ago


http://www.gastonsanchez.com


Browse source code at https://github.com/cran/pathdiagram


Authors: Gaston Sanchez


Documentation:   PDF Manual  


GPL-3 license


Depends on shape

Suggests knitr


See at CRAN