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, layout = NULL, output = NULL, title = NULL,
  width = NULL, height = NULL)

Arguments

graph

a graph object of class dgr_graph.

layout

a string specifying a layout type to use for node placement in this rendering. Possible layouts include: nicely, circle, tree, kk, and fr.

output

a string specifying the output type; graph (the default) renders the graph using the grViz function and visNetwork renders the graph using the visnetwork function.

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: 
# Render a graph that's a
# balanced tree
create_graph() %>%
  add_balanced_tree(
    k = 2, h = 3) %>%
  render_graph()

# Use the `tree` layout for
# better node placement in this
# hierarchical graph
create_graph() %>%
  add_balanced_tree(
    k = 2, h = 3) %>%
  render_graph(layout = "tree")

# Plot the same tree graph but
# don't show the node ID values
create_graph() %>%
  add_balanced_tree(
    k = 2, h = 3) %>%
  set_node_attr_to_display() %>%
  render_graph(layout = "tree")

# Create a circle graph
create_graph() %>%
  add_gnm_graph(
    n = 55,
    m = 75,
    set_seed = 23) %>%
  render_graph(
    layout = "circle")

# Render the graph using the
# `visNetwork` output option
create_graph() %>%
  add_balanced_tree(
    k = 2, h = 3) %>%
  render_graph(
    output = "visNetwork")

## End(Not run)

[Package DiagrammeR version 1.0.1 Index]