export_as_svg {causalHyperGraph}R Documentation

Export causal hypergraphs in svg format

Description

export_as_svg() exports the hypergraphs to svg files for editing with svg software.

Usage

export_as_svg(x, file, sep = "", verbose = TRUE)

Arguments

x

A graph generated with causalHyperGraph().

file

Character vector specifying file names for the graphs in x, optionally with a path. The file names must not include the extension ".svg", which will be appended automatically. file can be of length 1 or length(x). If length(file)<length(x), the name(s) in file is (are) recycled to length(x) and adjusted with make.unique().

sep

Separator passed to make.unique().

verbose

Logical; if TRUE (default), additional information about the file names is printed in the console. If FALSE, no information at all is printed.

Details

Although causalHyperGraph() optimizes the placement of the nodes and edges (using DiagrammeR) as much as possible, the resulting graph may still need manual adjustments to enhance its readability. In case of multi-value graphs, for example, factor values may be packed too closely or even printed on top of each other, calling for manual disentangling. Once the graphs have been exported via export_as_svg() such adjustments can be made with any svg software, such as Inkscape, Adobe Illustrator, or Apache Batik. Moreover, svg files can easily be converted to pdf or other formats.

Value

Returns the names of the generated file(s) invisibly.

See Also

causalHyperGraph, and the methods plot.cna.

Examples

library(cna)  # required for randomCsf() and allCombs()

# Manual crisp-set example.
x <- "(X+Y<->S)*(D+s*B<->E)*(A+S*B<->C)*(C+E<->F)"
gr1 <- causalHyperGraph(x)
export_as_svg(gr1, file.path(tempdir(), "csGraph"))

# Random multi-value example.
y <- randomCsf(allCombs(c(3,4,3,5,3,4)))
gr2 <- chg(y)
export_as_svg(gr2, file.path(tempdir(), "mvGraph"))

file.remove(file.path(tempdir(), c("csGraph.svg", "mvGraph.svg")))



[Package causalHyperGraph version 0.1.0 Index]