render_graph {DiagrammeR}R Documentation

Render the graph or output in various formats

Description

Using a dgr_graph object, either render graph in the Viewer or output in various formats.

Usage

render_graph(graph, output = NULL, layout = NULL, width = NULL,
  height = NULL)

Arguments

graph

a dgr_graph object, created using the create_graph function.

output

a string specifying the output type; graph (the default) renders the graph using the grViz function, vivagraph renders the graph using the vivagraph function, visNetwork renders the graph using the visnetwork function, and DOT outputs DOT code for the graph.

layout

a string specifying a layout type for a vivagraph rendering of the graph, either forceDirected or constant.

width

an optional parameter for specifying the width of the resulting graphic in pixels.

height

an optional parameter for specifying the height of the resulting graphic in pixels.

Examples

## Not run: 
# Create a node data frame (ndf)
nodes <-
  create_nodes(
    nodes = LETTERS,
    label = TRUE,
    type = "letter",
    shape = sample(c("circle", "square"),
                   length(LETTERS),
                   replace = TRUE),
    fillcolor = sample(c("aqua", "orange",
                         "pink", "lightgreen",
                         "black", "yellow"),
                       length(LETTERS),
                       replace = TRUE))

# Create an edge data frame (edf)
edges <-
  create_edges(
    from = sample(LETTERS, replace = TRUE),
    to = sample(LETTERS, replace = TRUE),
    rel = "letter_to_letter")

# Create a graph object using the ndf and edf, and,
# add a few attributes for the graph appearance
graph <-
  create_graph(
    nodes_df = nodes,
    edges_df = edges,
    graph_attrs = "layout = twopi",
    node_attrs = c("fontname = Helvetica",
                   "style = filled"),
    edge_attrs = c("color = gray20",
                   "arrowsize = 0.5"))

# Render the graph using Graphviz
render_graph(graph)

# Render the graph using VivaGraph
render_graph(graph, output = "vivagraph")

# Render the graph using visNetwork
render_graph(graph, output = "visNetwork")

## End(Not run)

[Package DiagrammeR version 0.8.4 Index]