render_graph {DiagrammeR}R Documentation

Render the graph in various formats

Description

Using a dgr_graph object, render the graph in the RStudio Viewer.

Usage

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

Arguments

graph

a graph object of class dgr_graph.

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, and visNetwork renders the graph using the visnetwork function.

layout

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

title

an optional title for a graph when using output = "graph".

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: 
# Set a seed
set.seed(24)

# Create a node data frame (ndf)
ndf <-
  create_node_df(
    n = 26,
    type = "basic",
    shape = sample(c("circle", "square"),
                   length(1:26),
                   replace = TRUE),
    fillcolor = sample(c("aqua", "orange",
                         "pink", "lightgreen",
                         "black", "yellow"),
                       length(1:26),
                       replace = TRUE))

# Create an edge data frame (edf)
edf <-
  create_edge_df(
    from = sample(1:26, replace = TRUE),
    to = sample(1:26, replace = TRUE),
    rel = "to_node")

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

# 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.9.0 Index]