add_edges_from_table {DiagrammeR} | R Documentation |
Add edges and their attributes to an existing graph object from data in a CSV file or a data frame.
add_edges_from_table(graph, table, from_col, from_mapping = NULL, to_col, to_mapping = NULL, set_rel = NULL, select_cols = NULL, drop_cols = NULL, rename_attrs = NULL, rel_col = NULL)
graph |
a graph object of class
|
table |
either a path to a CSV file, or, a data frame object. |
from_col |
the name of the table column from which edges originate. |
from_mapping |
a single character value for
the mapping of a column in the external table
(supplied as |
to_col |
the name of the table column to which edges terminate. |
to_mapping |
a single character value for
the mapping of a column in the external table
(supplied as |
set_rel |
an optional string to apply a
|
select_cols |
an optional character vector for specifying which columns in the table that should be imported as edge attributes. |
drop_cols |
an optional character vector for dropping columns from the incoming data. |
rename_attrs |
an optional character vector for renaming edge attributes. |
rel_col |
an option to apply a column of data
in the table as |
a graph object of class dgr_graph
.
## Not run: library(magrittr) library(dplyr) # Create a graph from a CSV file graph <- create_graph() %>% add_edges_from_table( system.file("examples/projects_and_contributors.csv", package = "DiagrammeR"), from_col = "contributor_name", to_col = "project_name", rel_col = "contributor_role", set_rel = "contributes_to") # Get a count of nodes in the graph node_count(graph) #> [1] 13 # Get a count of edges in the graph edge_count(graph) #> [1] 13 ## End(Not run)