export_graph: Export a graph to various file formats

Description Usage Arguments Examples

View source: R/export_graph.R

Description

Export a graph to a variety of file formats, including image formats such as PNG, PDF, SVG, and PostScript, and graph file formats such as GEXF.

Usage

1
2
export_graph(graph, file_name = NULL, file_type = NULL, title = NULL,
  width = NULL, height = NULL)

Arguments

graph

a graph object of class dgr_graph.

file_name

the name of the exported file (including it's extension).

file_type

the type of file to be exported. Options for graph files are: png, pdf, svg, and ps. Options for graph file formats are: gexf.

title

an optional title for the output graph.

width

output width in pixels or NULL for default. Only useful for export to image file formats png, pdf, svg, and ps.

height

output height in pixels or NULL for default. Only useful for export to image file formats png, pdf, svg, and ps.

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
34
35
36
37
## Not run: 
library(DiagrammeRsvg)

# Create a node data frame (ndf)
ndf <-
  create_node_df(
    n = 4,
    type = c("a", "a", "z", "z"),
    label = TRUE,
    value = c(3.5, 2.6, 9.4, 2.7))

# Create an edge data frame (edf)
edf <-
  create_edge_df(
    from = c(1, 2, 3),
    to = c(4, 3, 1),
    rel = c("rel_a", "rel_z", "rel_a"))

# Create a graph with the ndf and edf
graph <-
  create_graph(
    nodes_df = ndf,
    edges_df = edf)

# Create a PDF file for the graph (`graph.pdf`)
graph %>%
  export_graph(
    file_name = "graph.pdf",
    title = "Simple Graph")

# Create a PNG file for the graph (`mypng`)
graph %>%
  export_graph(
    file_name = "mypng",
    file_type = "PNG")

## End(Not run)

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.