Combine several vectors for edges and their attributes into a data frame, which can be combined with other similarly-generated data frames, or, added to a graph object. An edge data frame, or edf, has at least the following columns:
id(of typeinteger)from(of typeinteger)to(of typeinteger)rel(of typecharacter)
An arbitrary number of additional columns containing aesthetic or data
attributes can be part of the edf, so long as they follow the aforementioned
columns. Some examples are included in edge_aes()
Arguments
- from
A vector of node ID values from which edges are outbound. The vector length must equal that of the
tovector.- to
A vector of node ID values to which edges are incoming. The vector length must equal that of the
fromvector.- rel
An optional
rellabel for each edge.- ...
One or more vectors for associated edge attributes. Can be some of
edge_aes()
See also
Other edge creation and removal:
add_edge(),
add_edge_clone(),
add_edge_df(),
add_edges_from_table(),
add_edges_w_string(),
add_forward_edges_ws(),
add_reverse_edges_ws(),
copy_edge_attrs(),
delete_edge(),
delete_edges_ws(),
delete_loop_edges_ws(),
drop_edge_attrs(),
edge_data(),
join_edge_attrs(),
mutate_edge_attrs(),
mutate_edge_attrs_ws(),
recode_edge_attrs(),
rename_edge_attrs(),
rescale_edge_attrs(),
rev_edge_dir(),
rev_edge_dir_ws(),
set_edge_attr_to_display(),
set_edge_attrs(),
set_edge_attrs_ws()
Examples
# Create a simple edge data frame (edf) and
# view the results
edf <-
create_edge_df(
from = c(1, 2, 3),
to = c(4, 3, 1),
rel = "a")
# Display the edge data frame
edf
#> id from to rel
#> 1 1 1 4 a
#> 2 2 2 3 a
#> 3 3 3 1 a
# Create an edf with additional edge
# attributes (where their classes will
# be inferred from the input vectors)
edf <-
create_edge_df(
from = c(1, 2, 3),
to = c(4, 3, 1),
rel = "a",
length = c(50, 100, 250),
color = "green",
width = c(1, 5, 2))
# Display the edge data frame
edf
#> id from to rel length color width
#> 1 1 1 4 a 50 green 1
#> 2 2 2 3 a 100 green 5
#> 3 3 3 1 a 250 green 2