#' Recursively join a list of tidygraphs
#'
#' Joins the graphs into a single graph. This recursively implementes
#' \code{tidygraph::graph_join()}
#'
#' @param grs a list of tidygraph objects
#' @param by what to group by (passed to \code{tidygraph::graph_join()})
#'
#' @return a single tidygraph object
#'
#' @examples
#' set.seed(0)
#'
#' gr_list <- purrr::map(c(10, 15, 20), quick_forestfire)
#' gr <- recursive_graph_join(gr_list)
#' gr
#'
#' plot(gr)
#'
#' @export recursive_graph_join
recursive_graph_join <- function(grs, by = "name") {
if (length(grs) == 1) {
# base case
return(grs[[1]])
} else {
# recurse
GR <- tidygraph::graph_join(grs[[1]],
recursive_graph_join(grs[-1], by = by),
by = by)
}
return(GR)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.