scale_edges: Create numerical and color scales for edge attributes

Description Usage Arguments Value Examples

Description

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

Usage

1
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 provided.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# 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))

## End(Not run)

garyfeng/pdata documentation built on May 16, 2019, 5:42 p.m.