diff --git a/NEWS.md b/NEWS.md index 707d9d53..be80bd95 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ * Fix a bug in `geom_edge_parallel()` when used with edge labels. Edges are now correctly offset, though label may still overlap (#227) * Fix a bug with auto layout on undirected trees (#247) +* Fix a bug in `get_con()` that would lead to wrong matching of additional data + (#249) # ggraph 2.1.0 diff --git a/R/connections.R b/R/connections.R index 4b0c09a8..dbe8cfb1 100644 --- a/R/connections.R +++ b/R/connections.R @@ -55,7 +55,9 @@ get_con <- function(from = integer(), to = integer(), paths = NULL, ..., weight ) nodes <- vec_rbind(nodes, extra) } - extra_data <- lapply(list2(...), rep, length.out = nrow(nodes)) + extra_data <- lapply(list2(...), function(x) { + rep(x, length.out = length(from))[nodes$con.id] + }) if (length(extra_data) > 0) { nodes <- cbind( nodes,