Read and write text representations of models
read.digraph(file, labels = NULL) parse.digraph(lines, labels = NULL) deparse.digraph(edges) write.digraph(edges, file = "")
| file | the name of the file to read or write |
|---|---|
| labels | the sequence of labels to use for the nodes |
| lines | a string representation of the model |
| edges | an edge list. |
The write.digraph function invisibly returns the
text that was written to the file.
The functions read.digraph and parse.digraph return an
edge list - a data frame with columns
Froma factor indicating the origin of each edge (the node that effects)
Toa factor indicating the destination of each edge (the node that is effected)
Groupan integer vector that indicates the group each edge belons to
Typea factor indicating the edge type - "N" (negative) ,"P" (positive),"U" (unknown) or "Z" (zero)
Pairan integer vector that indicates the pairing of directed edges
The functions read.digraph and parse.digraph read a model
description from a text file and a string respectively, while
write.digraph writes a text representation of the model to and
file.
These functions recognize the following text format. Each line corresponds to an edge, and must consist of two node labels separated by an arrow. An arrow consists of one of the character sequences "<","*","<>" or "" on the left and ">","*","<>" or "" on the right, separated by a sequence of dashes "-". The number of dashes used in the arrow defines the group number of the edge.
edges <- parse.digraph(c("A <-* B","C *-> A","C <- D","D -> B","B *--* C","A <--- D")) edges#> From To Group Type Pair #> 1 A B 0 N 1 #> 2 C A 0 P 2 #> 4 D B 0 P 4 #> 5 B C 1 N 5 #> 7 B A 0 P 1 #> 8 A C 0 N 2 #> 9 D C 0 P 3 #> 11 C B 1 N 5 #> 12 D A 2 P 6deparse.digraph(edges)#> 1.0 2.0 3.0 4.0 5.1 6.2 #> "B *-> A" "C *-> A" "D -> C" "D -> B" "B *--* C" "D ---> A"