ggnetwork icon indicating copy to clipboard operation
ggnetwork copied to clipboard

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

Open Prenauer opened this issue 4 months ago • 3 comments

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:

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

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.

Prenauer avatar Oct 16 '24 01:10 Prenauer