Skip to content

Commit

Permalink
Fix #364 and fix #365
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Mar 7, 2024
1 parent cb8d202 commit 27ba75a
Show file tree
Hide file tree
Showing 42 changed files with 124 additions and 122 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggraph (development version)

* Rolling back use of native pipe (#364 and #365)

# ggraph 2.2.0

* Fix a precision bug in circle pack layout (#345)
Expand Down
2 changes: 1 addition & 1 deletion R/autograph.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' @examples
#' library(tidygraph)
#' gr <- create_notable('herschel') |>
#' gr <- create_notable('herschel') %>%
#' mutate(class = sample(letters[1:3], n(), TRUE)) %E>%
#' mutate(weight = runif(n()))
#'
Expand Down
12 changes: 6 additions & 6 deletions R/edges.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ collapse_all_edges <- function(edges) {
id <- paste(from, to, sep = '-')
if (anyDuplicated(id)) {
edges$.id <- id
edges <- edges |>
group_by(.data$.id) |>
top_n(1) |>
edges <- edges %>%
group_by(.data$.id) %>%
top_n(1) %>%
ungroup()
}
data_frame0(edges)
Expand All @@ -217,9 +217,9 @@ collapse_dir_edges <- function(edges) {
id <- paste(edges$from, edges$to, sep = '-')
if (anyDuplicated(id)) {
edges$.id <- id
edges <- edges |>
group_by(.data$.id) |>
top_n(1) |>
edges <- edges %>%
group_by(.data$.id) %>%
top_n(1) %>%
ungroup()
}
data_frame0(edges)
Expand Down
2 changes: 1 addition & 1 deletion R/facet_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#'
#' @examples
#' library(tidygraph)
#' gr <- as_tbl_graph(highschool) |>
#' gr <- as_tbl_graph(highschool) %>%
#' mutate(popularity = as.character(cut(centrality_degree(mode = 'in'),
#' breaks = 3,
#' labels = c('low', 'medium', 'high')
Expand Down
2 changes: 1 addition & 1 deletion R/facet_nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#'
#' @examples
#' library(tidygraph)
#' gr <- as_tbl_graph(highschool) |>
#' gr <- as_tbl_graph(highschool) %>%
#' mutate(popularity = as.character(cut(centrality_degree(mode = 'in'),
#' breaks = 3,
#' labels = c('low', 'medium', 'high')
Expand Down
18 changes: 9 additions & 9 deletions R/geom_axis_hive.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#' @export
StatAxisHive <- ggproto('StatAxisHive', StatFilter,
setup_data = function(data, params) {
data <- data |>
group_by(.data$angle, .data$section, .data$PANEL) |>
data <- data %>%
group_by(.data$angle, .data$section, .data$PANEL) %>%
mutate(
x = min(.data$r) * cos(.data$angle[1]) * 1.1,
y = min(.data$r) * sin(.data$angle[1]) * 1.1,
xend = max(.data$r) * cos(.data$angle[1]) * 1.1,
yend = max(.data$r) * sin(.data$angle[1]) * 1.1,
max_r = max(.data$r),
min_r = min(.data$r)
) |>
slice(1) |>
) %>%
slice(1) %>%
ungroup()
data_frame0(data)
},
Expand All @@ -35,8 +35,8 @@ GeomAxisHive <- ggproto('GeomAxisHive', GeomSegment,
data$xend <- data$xend / 1.1
data$yend <- data$yend / 1.1
data <- coord$transform(data, panel_scales)
label_data <- data |>
group_by(.data$axis) |>
label_data <- data %>%
group_by(.data$axis) %>%
summarise(
x = max(.data$max_r) * cos(mean(.data$angle)),
y = max(.data$max_r) * sin(mean(.data$angle)),
Expand Down Expand Up @@ -132,15 +132,15 @@ GeomAxisHive <- ggproto('GeomAxisHive', GeomSegment,
#' @examples
#' # Plot the flare import graph as a hive plot
#' library(tidygraph)
#' flareGr <- as_tbl_graph(flare$imports) |>
#' flareGr <- as_tbl_graph(flare$imports) %>%
#' mutate(
#' type = dplyr::case_when(
#' centrality_degree(mode = 'in') == 0 ~ 'Source',
#' centrality_degree(mode = 'out') == 0 ~ 'Sink',
#' TRUE ~ 'Both'
#' )
#' ) |>
#' activate(edges) |>
#' ) %>%
#' activate(edges) %>%
#' mutate(
#' type = dplyr::case_when(
#' grepl('flare.analytics', paste(.N()$name[from], .N()$name[to])) ~ 'Analytics',
Expand Down
2 changes: 1 addition & 1 deletion R/geom_conn_bundle.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#' @examples
#' # Create a graph of the flare class system
#' library(tidygraph)
#' flareGraph <- tbl_graph(flare$vertices, flare$edges) |>
#' flareGraph <- tbl_graph(flare$vertices, flare$edges) %>%
#' mutate(
#' class = map_bfs_chr(node_is_root(), .f = function(node, dist, path, ...) {
#' if (dist <= 1) {
Expand Down
10 changes: 5 additions & 5 deletions R/geom_edge_arc.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
#' @examples
#' require(tidygraph)
#' # Make a graph with different directions of edges
#' gr <- create_notable('Meredith') |>
#' convert(to_directed) |>
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) |>
#' activate(edges) |>
#' gr <- create_notable('Meredith') %>%
#' convert(to_directed) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) %>%
#' activate(edges) %>%
#' mutate(
#' class = sample(letters[1:3], n(), replace = TRUE),
#' switch = sample(c(TRUE, FALSE), n(), replace = TRUE)
#' ) |>
#' ) %>%
#' reroute(from = to, to = from, subset = switch)
#'
#' ggraph(gr, 'linear') +
Expand Down
6 changes: 3 additions & 3 deletions R/geom_edge_bend.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_tree(20, 4) |>
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) |>
#' activate(edges) |>
#' gr <- create_tree(20, 4) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) %>%
#' activate(edges) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'tree') +
Expand Down
4 changes: 2 additions & 2 deletions R/geom_edge_density.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' activate(edges) |>
#' gr <- create_notable('bull') %>%
#' activate(edges) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'stress') +
Expand Down
6 changes: 3 additions & 3 deletions R/geom_edge_diagonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_tree(20, 4) |>
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) |>
#' activate(edges) |>
#' gr <- create_tree(20, 4) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) %>%
#' activate(edges) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'tree') +
Expand Down
8 changes: 4 additions & 4 deletions R/geom_edge_elbow.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
#'
#' @examples
#' require(tidygraph)
#' irisDen <- hclust(dist(iris[1:4], method = 'euclidean'), method = 'ward.D2') |>
#' as_tbl_graph() |>
#' mutate(class = sample(letters[1:3], n(), TRUE)) |>
#' activate(edges) |>
#' irisDen <- hclust(dist(iris[1:4], method = 'euclidean'), method = 'ward.D2') %>%
#' as_tbl_graph() %>%
#' mutate(class = sample(letters[1:3], n(), TRUE)) %>%
#' activate(edges) %>%
#' mutate(class = sample(letters[1:3], n(), TRUE))
#'
#' ggraph(irisDen, 'dendrogram', circular = TRUE) +
Expand Down
18 changes: 9 additions & 9 deletions R/geom_edge_fan.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' convert(to_directed) |>
#' gr <- create_notable('bull') %>%
#' convert(to_directed) %>%
#' bind_edges(data.frame(from = c(1, 2, 2, 3), to = c(2, 1, 3, 2))) %E>%
#' mutate(class = sample(letters[1:3], 9, TRUE)) %N>%
#' mutate(class = sample(c('x', 'y'), 5, TRUE))
Expand Down Expand Up @@ -254,13 +254,13 @@ geom_edge_fan0 <- function(mapping = NULL, data = get_edges(),
create_fans <- function(from, to, params) {
from$.id <- paste(pmin(from$from, to$to), pmax(from$from, to$to), sep = '-')
from$.orig_ind <- seq_len(nrow(from))
position <- from |>
group_by(.data$PANEL, .data$.id) |>
arrange(.data$from) |>
mutate(position = seq_len(n()) - 0.5 - n() / 2) |>
mutate(position = .data$position * ifelse(.data$from < .data$to, 1, -1)) |>
ungroup() |>
arrange(.data$.orig_ind) |>
position <- from %>%
group_by(.data$PANEL, .data$.id) %>%
arrange(.data$from) %>%
mutate(position = seq_len(n()) - 0.5 - n() / 2) %>%
mutate(position = .data$position * ifelse(.data$from < .data$to, 1, -1)) %>%
ungroup() %>%
arrange(.data$.orig_ind) %>%
transmute(position = .data$position)
position <- position$position
max_fans <- max(table(from$.id))
Expand Down
6 changes: 3 additions & 3 deletions R/geom_edge_hive.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
#' @examples
#' # Plot the flare import graph as a hive plot
#' library(tidygraph)
#' flareGr <- as_tbl_graph(flare$imports) |>
#' flareGr <- as_tbl_graph(flare$imports) %>%
#' mutate(
#' type = dplyr::case_when(
#' centrality_degree(mode = 'in') == 0 ~ 'Source',
#' centrality_degree(mode = 'out') == 0 ~ 'Sink',
#' TRUE ~ 'Both'
#' )
#' ) |>
#' activate(edges) |>
#' ) %>%
#' activate(edges) %>%
#' mutate(
#' type = dplyr::case_when(
#' grepl('flare.analytics', paste(.N()$name[from], .N()$name[to])) ~ 'Analytics',
Expand Down
6 changes: 3 additions & 3 deletions R/geom_edge_link.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) |>
#' activate(edges) |>
#' gr <- create_notable('bull') %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) %>%
#' activate(edges) %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'stress') +
Expand Down
18 changes: 9 additions & 9 deletions R/geom_edge_parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' convert(to_directed) |>
#' gr <- create_notable('bull') %>%
#' convert(to_directed) %>%
#' bind_edges(data.frame(from = c(1, 2, 2, 3), to = c(2, 1, 3, 2))) %E>%
#' mutate(class = sample(letters[1:3], 9, TRUE)) %N>%
#' mutate(class = sample(c('x', 'y'), 5, TRUE))
Expand Down Expand Up @@ -234,12 +234,12 @@ geom_edge_parallel0 <- function(mapping = NULL, data = get_edges(),
edge_positions <- function(from, to, params) {
from$.id <- paste(pmin(from$from, to$to), pmax(from$from, to$to), sep = '-')
from$.orig_ind <- seq_len(nrow(from))
from |>
group_by(.data$PANEL, .data$.id) |>
arrange(.data$from) |>
mutate(position = seq_len(n()) - 0.5 - n() / 2) |>
mutate(position = .data$position * ifelse(.data$from < .data$to, 1, -1)) |>
ungroup() |>
arrange(.data$.orig_ind) |>
from %>%
group_by(.data$PANEL, .data$.id) %>%
arrange(.data$from) %>%
mutate(position = seq_len(n()) - 0.5 - n() / 2) %>%
mutate(position = .data$position * ifelse(.data$from < .data$to, 1, -1)) %>%
ungroup() %>%
arrange(.data$.orig_ind) %>%
pull(.data$position)
}
10 changes: 5 additions & 5 deletions R/geom_edge_point.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('zachary') |>
#' mutate(group = group_infomap()) |>
#' morph(to_split, group) |>
#' activate(edges) |>
#' mutate(edge_group = as.character(.N()$group[1])) |>
#' gr <- create_notable('zachary') %>%
#' mutate(group = group_infomap()) %>%
#' morph(to_split, group) %>%
#' activate(edges) %>%
#' mutate(edge_group = as.character(.N()$group[1])) %>%
#' unmorph()
#'
#' ggraph(gr, 'matrix', sort.by = node_rank_hclust()) +
Expand Down
10 changes: 5 additions & 5 deletions R/geom_edge_tile.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('zachary') |>
#' mutate(group = group_infomap()) |>
#' morph(to_split, group) |>
#' activate(edges) |>
#' mutate(edge_group = as.character(.N()$group[1])) |>
#' gr <- create_notable('zachary') %>%
#' mutate(group = group_infomap()) %>%
#' morph(to_split, group) %>%
#' activate(edges) %>%
#' mutate(edge_group = as.character(.N()$group[1])) %>%
#' unmorph()
#'
#' ggraph(gr, 'matrix', sort.by = node_rank_hclust()) +
Expand Down
2 changes: 1 addition & 1 deletion R/geom_node_point.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' gr <- create_notable('bull') %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'stress') + geom_node_point()
Expand Down
2 changes: 1 addition & 1 deletion R/geom_node_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('bull') |>
#' gr <- create_notable('bull') %>%
#' mutate(class = sample(letters[1:3], n(), replace = TRUE))
#'
#' ggraph(gr, 'stress') +
Expand Down
2 changes: 1 addition & 1 deletion R/geom_node_tile.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' @examples
#' # Create a graph of the flare class system
#' library(tidygraph)
#' flareGraph <- tbl_graph(flare$vertices, flare$edges) |>
#' flareGraph <- tbl_graph(flare$vertices, flare$edges) %>%
#' mutate(
#' class = map_bfs_chr(node_is_root(), .f = function(node, dist, path, ...) {
#' if (dist <= 1) {
Expand Down
2 changes: 1 addition & 1 deletion R/geom_node_voronoi.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#'
#' @examples
#' require(tidygraph)
#' gr <- create_notable('meredith') |>
#' gr <- create_notable('meredith') %>%
#' mutate(group = sample(letters[1:4], n(), TRUE))
#'
#' ggraph(gr) +
Expand Down
2 changes: 1 addition & 1 deletion man/autograph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/facet_graph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/facet_nodes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 27ba75a

Please sign in to comment.