read.digraph: Text Representations of Models

View source: R/text.R

read.digraphR Documentation

Text Representations of Models

Description

Read and write text representations of models

Usage

read.digraph(file, labels = NULL)

parse.digraph(lines, labels = NULL)

deparse.digraph(edges)

write.digraph(edges, file = "")

Arguments

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.

Details

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.

Value

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

From

a factor indicating the origin of each edge (the node that effects)

To

a factor indicating the destination of each edge (the node that is effected)

Group

an integer vector that indicates the group each edge belongs to

Type

a factor indicating the edge type - "N" (negative) ,"P" (positive),"U" (unknown) or "Z" (zero)

Pair

an integer vector that indicates the pairing of directed edges

Each edge of the text specification is separated into two directed edges, and every row of an edge list corresponds to a single directed edge.

Examples

edges <- parse.digraph(c("A <-* B","C *-> A","C <- D",
    "D -> B","B *--* C","A <--- D"))
edges
deparse.digraph(edges)

SWotherspoon/QPress documentation built on Sept. 26, 2022, 2:27 a.m.