## File: bind_graphs.Rd

package info (click to toggle)
r-cran-tidygraph 1.2.0-1
• links: PTS, VCS
• area: main
• in suites: bullseye, sid
• size: 736 kB
• sloc: cpp: 35; sh: 13; makefile: 2
 file content (57 lines) | stat: -rw-r--r-- 2,069 bytes parent folder | download
 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 % Generated by roxygen2: do not edit by hand % Please edit documentation in R/bind.R \name{bind_graphs} \alias{bind_graphs} \alias{bind_nodes} \alias{bind_edges} \title{Add graphs, nodes, or edges to a tbl_graph} \usage{ bind_graphs(.data, ...) bind_nodes(.data, ...) bind_edges(.data, ..., node_key = "name") } \arguments{ \item{.data}{A \code{tbl_graph}, or a list of \code{tbl_graph} objects (for \code{bind_graphs()}).} \item{...}{In case of \code{bind_nodes()} and \code{bind_edges()} data.frames to add. In the case of \code{bind_graphs()} objects that are convertible to \code{tbl_graph} using \code{as_tbl_graph()}.} \item{node_key}{The name of the column in \code{nodes} that character represented \code{to} and \code{from} columns should be matched against. If \code{NA} the first column is always chosen. This setting has no effect if \code{to} and \code{from} are given as integers.} } \value{ A \code{tbl_graph} containing the new data } \description{ These functions are tbl_graph pendants to \code{\link[dplyr:bind_rows]{dplyr::bind_rows()}} that allows you to grow your \code{tbl_graph} by adding rows to either the nodes data, the edges data, or both. As with \code{bind_rows()} columns are matched by name and are automatically filled with \code{NA} if the column doesn't exist in some instances. In the case of \code{bind_graphs()} the graphs are automatically converted to \code{tbl_graph} objects prior to binding. The edges in each graph will continue to reference the nodes in the graph where they originated, meaning that their terminal node indexes will be shifted to match the new index of the node in the combined graph. This means the \code{bind_graphs()} always result in a disconnected graph. See \code{\link[=graph_join]{graph_join()}} for merging graphs on common nodes. } \examples{ graph <- create_notable('bull') new_graph <- create_notable('housex') # Add nodes graph \%>\% bind_nodes(data.frame(new = 1:4)) # Add edges graph \%>\% bind_edges(data.frame(from = 1, to = 4:5)) # Add graphs graph \%>\% bind_graphs(new_graph) }