diff --git a/DESCRIPTION b/DESCRIPTION index 39720286..803b41f5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -50,7 +50,7 @@ Suggests: covr, sf LinkingTo: Rcpp -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Depends: R (>= 2.10), ggplot2 (>= 3.0.0) diff --git a/NAMESPACE b/NAMESPACE index 826cac2f..d9f53144 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,9 @@ S3method(as.data.frame,layout_ggraph) S3method(autograph,default) +S3method(collect_connections,default) +S3method(collect_edges,default) +S3method(collect_edges,layout_tbl_graph) S3method(create_layout,default) S3method(create_layout,layout_ggraph) S3method(create_layout,tbl_graph) diff --git a/R/connections.R b/R/connections.R index 39684319..1d492f46 100644 --- a/R/connections.R +++ b/R/connections.R @@ -91,6 +91,7 @@ get_con <- function(from = integer(), to = integer(), paths = NULL, ..., weight collect_connections <- function(layout, from, to, ...) { UseMethod('collect_connections', layout) } +#' @export collect_connections.default <- function(layout, ...) { cli::cli_abort('Don\'t know how to get connections from an object of class {.cls {class(layout)[1]}}') } diff --git a/R/edges.R b/R/edges.R index 2825e1d3..537851ce 100644 --- a/R/edges.R +++ b/R/edges.R @@ -110,6 +110,7 @@ get_edges <- function(format = 'short', collapse = 'none', ...) { collect_edges <- function(layout) { UseMethod('collect_edges', layout) } +#' @export collect_edges.default <- function(layout) { attr(layout, 'edges') } diff --git a/R/geom_edge_sf.R b/R/geom_edge_sf.R index fd38de12..20fd4246 100644 --- a/R/geom_edge_sf.R +++ b/R/geom_edge_sf.R @@ -43,7 +43,7 @@ geom_edge_sf <- function(mapping = NULL, data = get_sf_edges(), coord_sf(default = TRUE) ) } - +#' @rdname get_edges get_sf_edges <- function(){ function(layout) { edges <- sf::st_as_sf(attr(layout, "graph"), "edges") diff --git a/R/geom_node_sf.R b/R/geom_node_sf.R index db1a0b9a..50f7d92e 100644 --- a/R/geom_node_sf.R +++ b/R/geom_node_sf.R @@ -45,10 +45,11 @@ geom_node_sf <- function(mapping = NULL, data = get_sf_nodes(), ) } +#' @rdname get_nodes get_sf_nodes <- function(){ function(layout) { nodes <- sf::st_as_sf(layout) attr(nodes, 'type_ggraph') <- 'node_ggraph' nodes } -} \ No newline at end of file +} diff --git a/R/tbl_graph.R b/R/tbl_graph.R index 703390ba..bf76681e 100644 --- a/R/tbl_graph.R +++ b/R/tbl_graph.R @@ -27,6 +27,7 @@ create_layout.tbl_graph <- function(graph, layout, circular = FALSE, ...) { ) check_layout(layout) } +#' @export collect_edges.layout_tbl_graph <- function(layout) { gr <- attr(layout, 'graph') edges <- as_tibble(gr, active = 'edges') diff --git a/_pkgdown.yml b/_pkgdown.yml index 8349cabf..06b8ea7b 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -79,6 +79,8 @@ reference: - layout_tbl_graph_matrix - layout_tbl_graph_hive - layout_tbl_graph_fabric + - layout_tbl_graph_sf + - layout_tbl_graph_metro - title: "Nodes" desc: > While nodes are often thought of as points in a hairball graph, they are @@ -91,6 +93,7 @@ reference: - geom_node_circle - geom_node_arc_bar - geom_node_range + - geom_node_sf - title: "Edges" desc: > Edges are the entities connecting nodes, often drawn with some sort of @@ -113,6 +116,7 @@ reference: - geom_edge_bundle_force - geom_edge_bundle_path - geom_edge_bundle_minimal + - geom_edge_sf - title: "Connections" desc: > Connections are meta-edges, connecting nodes that are not direct diff --git a/man/get_con.Rd b/man/get_con.Rd index 4136fcb5..df2f61a4 100644 --- a/man/get_con.Rd +++ b/man/get_con.Rd @@ -52,6 +52,6 @@ connection. \seealso{ Other extractors: \code{\link{get_edges}()}, -\code{\link{get_nodes}()} +\code{\link{get_sf_nodes}()} } \concept{extractors} diff --git a/man/get_edges.Rd b/man/get_edges.Rd index 2d345a7c..1c2cbba3 100644 --- a/man/get_edges.Rd +++ b/man/get_edges.Rd @@ -1,10 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/edges.R +% Please edit documentation in R/edges.R, R/geom_edge_sf.R \name{get_edges} \alias{get_edges} +\alias{get_sf_edges} \title{Create edge extractor function} \usage{ get_edges(format = "short", collapse = "none", ...) + +get_sf_edges() } \arguments{ \item{format}{Either \code{'short'} (the default) or \code{'long'}. See @@ -80,6 +83,6 @@ ggraph. \seealso{ Other extractors: \code{\link{get_con}()}, -\code{\link{get_nodes}()} +\code{\link{get_sf_nodes}()} } \concept{extractors} diff --git a/man/get_nodes.Rd b/man/get_nodes.Rd index 9a287a4a..f8ffdc2e 100644 --- a/man/get_nodes.Rd +++ b/man/get_nodes.Rd @@ -1,9 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nodes.R -\name{get_nodes} +% Please edit documentation in R/geom_node_sf.R, R/nodes.R +\name{get_sf_nodes} +\alias{get_sf_nodes} \alias{get_nodes} \title{Create a node extractor function} \usage{ +get_sf_nodes() + get_nodes(...) } \arguments{ diff --git a/man/ggraph-package.Rd b/man/ggraph-package.Rd index acac9dc6..ddb395b8 100644 --- a/man/ggraph-package.Rd +++ b/man/ggraph-package.Rd @@ -3,7 +3,6 @@ \docType{package} \name{ggraph-package} \alias{ggraph-package} -\alias{_PACKAGE} \title{ggraph: An Implementation of Grammar of Graphics for Graphs and Networks} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} diff --git a/man/layout_tbl_graph_metro.Rd b/man/layout_tbl_graph_metro.Rd index 5fd345c4..669986fd 100644 --- a/man/layout_tbl_graph_metro.Rd +++ b/man/layout_tbl_graph_metro.Rd @@ -11,7 +11,8 @@ layout_tbl_graph_metro( length = 2, grid_space = 0.0025, optimization_weights = NULL, - max_movement = 5 + max_movement = 5, + circular = FALSE ) } \arguments{ @@ -88,6 +89,7 @@ Other layout_tbl_graph_*: \code{\link{layout_tbl_graph_matrix}()}, \code{\link{layout_tbl_graph_partition}()}, \code{\link{layout_tbl_graph_pmds}()}, +\code{\link{layout_tbl_graph_sf}()}, \code{\link{layout_tbl_graph_stress}()}, \code{\link{layout_tbl_graph_treemap}()}, \code{\link{layout_tbl_graph_unrooted}()} diff --git a/man/layout_tbl_graph_sf.Rd b/man/layout_tbl_graph_sf.Rd index 579db56b..33e13450 100644 --- a/man/layout_tbl_graph_sf.Rd +++ b/man/layout_tbl_graph_sf.Rd @@ -35,6 +35,7 @@ Other layout_tbl_graph_*: \code{\link{layout_tbl_graph_linear}()}, \code{\link{layout_tbl_graph_manual}()}, \code{\link{layout_tbl_graph_matrix}()}, +\code{\link{layout_tbl_graph_metro}()}, \code{\link{layout_tbl_graph_partition}()}, \code{\link{layout_tbl_graph_pmds}()}, \code{\link{layout_tbl_graph_stress}()},