draw: Draw manifest and latent variables

Description Usage Arguments Author(s) See Also Examples

View source: R/draw.R

Description

Use this function to draw either manifest or latent variables on a plot.

Usage

1
  draw(obj)

Arguments

obj

An object of either class "manifest" or "latent"

Author(s)

Gaston Sanchez

See Also

manifest, latent

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
 # manifest variables
 ingredients = list(
   eggs = manifest("eggs", x=0.3, y=0.7, width=0.10, height=0.08),
   milk = manifest("milk", x=0.3, y=0.6, width=0.10, height=0.08),
   flour = manifest("flour", x=0.3, y=0.5, width=0.10, height=0.08),
   sugar = manifest("sugar", x=0.3, y=0.4, width=0.10, height=0.08),
   butter = manifest("butter", x=0.3, y=0.3, width=0.10, height=0.08)
 )

 # latent variables
 pancakes = latent("PANCAKES", x=0.6, y=0.6, rx=0.09, ry=0.07)
 waffles = latent("WAFFLES", x=0.6, y=0.4, rx=0.09, ry=0.07)

 # open wall
 wall()

 title("Toy Path Diagram", col.main="gray20")
 # draw manifest variables
 for (i in 1:length(ingredients)) {
    draw(ingredients[[i]])
 }

 # draw latent variables
 draw(pancakes)
 draw(waffles)
 # draw arrows
 for (i in 1:length(ingredients)) {
    arrow(from=ingredients[[i]], to=pancakes, start="east", end="west")
    arrow(from=ingredients[[i]], to=waffles, start="east", end="west")
 }
 
## End(Not run)

Example output

Loading required package: shape

pathdiagram documentation built on Oct. 2, 2019, 5:03 p.m.