[R] path-diagram wirh Rgraphvis
René Mayer
mayer at psychologie.tu-dresden.de
Fri Jul 27 20:32:34 CEST 2012
Dear List,
how can I draw the following path diagram
A B C D E F
\ | / \ | /
G <--> H
/ \ / \
I J K L
the problem I've got is that G and H need to be horizontally alingned
but the best I've done is diagonally or vertically alingned,
kind regards,
Rene
## Begin: R-code
#source("http://bioconductor.org/biocLite.R")
#biocLite("Rgraphviz")
library(Rgraphviz)
library("graph")
# observed x
ox=c('RParAsp', 'RIQ', 'RSES','FSES', 'FIQ', 'FParAsp')
# observed y
oy=c('ROccAsp', 'REdAsp', 'FOccAsp', 'FEdAsp')
# latend
l=c('FGenAsp','RGenAsp')
# pure nodes in a line
l1 <- new("graphNEL", nodes = c(ox,oy,l), edgemode = "directed")
plot(l1, "dot")
l1 <- addEdge("RParAsp", "RGenAsp", l1)
l1 <- addEdge("RIQ", "RGenAsp", l1)
l1 <- addEdge("RSES", "RGenAsp", l1)
l1 <- addEdge("FParAsp", "FGenAsp", l1)
l1 <- addEdge("FIQ", "FGenAsp", l1)
l1 <- addEdge("FSES", "FGenAsp", l1)
l1 <- addEdge("FGenAsp", "FOccAsp", l1)
l1 <- addEdge("FGenAsp", "FEdAsp", l1)
l1 <- addEdge("RGenAsp", "ROccAsp", l1)
l1 <- addEdge("RGenAsp", "REdAsp", l1)
l1 <- addEdge("RGenAsp", "FGenAsp", l1)
l1 <- addEdge("FGenAsp", "RGenAsp", l1)
plot(l1, recipEdges="distinct")
sub1 <- subGraph(ox, l1)
sub2 <- subGraph(oy, l1)
sub3 <- subGraph(l, l1)
sublist <-
list( list(graph=sub1, cluster = T) ,
list(graph=sub2, cluster = T),
list(graph=sub3, cluster = T)
)
plot(l1,
subGList = sublist)
globalattrs$graph <- list(rankdir = "LR")
plot(l1, attrs = globalattrs)
## End: R-code
More information about the R-help
mailing list