Learn R Programming

DiagrammeR (version 0.7)

scale_edges: Create numerical and color scales for edge attributes

Description

Generates either numeric or color scales for specified edge attributes and applies those scales to edge data frames.

Usage

scale_edges(edges_df, to_scale, edge_attr, range, scale_type = "linear")

Arguments

edges_df
a data frame containing, at minimum, a column (called edge_op) with edge operations as character strings (in the form of [node_id] -> [node_id]). Alternatively, there may be two columns where node IDs specifying edges are provide
to_scale
a vector of numerical values to be scaled; these currently need to be of the same length and order as the edge operations in the supplied edge data frame, so, it's recommended to reference a column of values available in edges_df.
edge_attr
the name of the edge attribute for which scaled values are to be created.
range
a vector of 2 elements providing either lower and upper numerical or X11 color values.
scale_type
the type of scaling to perform. Currently, linear is the only option available.

Value

  • an edge data frame.

Examples

Run this code
# Add an edge attribute which has values scaled to
# numeric data in another column
edges <- create_edges(from = c("a", "b", "c"),
                      to = c("d", "d", "a"),
                      label = '',
                      relationship = "given_to",
                      data = sample(seq(1:50), 10))

edges <- scale_edges(edges_df = edges,
                     to_scale = edges$data,
                     edge_attr = "penwidth",
                     range = c(1, 5))

Run the code above in your browser using DataLab