briatte / briatte/ggnetwork

ggnetwork function Error in rbind(deparse.level, ...)

Open
#78 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
154
Forks
29
PR merge metrics
No merged PRs in 30d

Description

I had trouble using the ggnetwork() function and got the following error:
Error in rbind(deparse.level, ...) :
numbers of columns of arguments do not match

I looked into the code and found that format_fortify() included some code that doesn't seem to work:
```r
edges <- merge(nodes, edges, by = c("x", "y"), all = TRUE)
```
This strategy might not work for a lot of situations, in which the edges data.frame already has columns with the same names as those with the nodes data.frame.

I fixed this changing the code to below
```r
edges <- merge(nodes[, c("x", "y", setdiff(names(nodes),
names(edges)))], edges, by = c("x", "y"), all = TRUE)
```
This way, it doesn't matter what columns were previously present in edges and nodes.

Hope this helps.

Contributor guide

Open the contributing guide

Research direction

Start with the format_fortify() code used by ggnetwork(), focusing on the merge of nodes and edges in the issue. Reproduce the reported rbind error with ggnetwork(), then verify that inputs with overlapping column names are handled without the numbers-of-columns error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.