srrein
srrein

Reputation: 33

rbind (deparse level) error when plotting with ggnetwork

I have the following problem: When plotting a network with either ggnet2() or plot(), it works perfectly fine, but when I switch to ggnetwork(), I get the following error:

Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match

What is ggnetwork trying to rbind?

Here some of my code - I'm not an R pro so please let me know if you need more

edges$weight <- as.numeric(edges$weight)

nodes <- read.csv("D:/EP..., stringsAsFactors = F, sep=";")
names(nodes) <- c("ID", "vertex.names", "aktyp", "scope", "country", "party", "aktyp_recod", "scope_recod", "country_recod")

graph <- graph_from_data_frame(edges, directed = T, vertices = nodes)
is.weighted(graph) #true

network <- network(edges, vertex.attr = nodes, directed =T, multiple =F, loops=T)
c <- edges$weight
set.edge.value(network, "weight", c)
get.edge.value(network, "weight") # is weighted 

It happens both when passing the network object and the graph object through ggnetwork.

From the traceback, it seems that ggnetwork is trying to rbind the edgelist and nodelist? Which are obviously not the same length, because there are more connections than nodes.

Error in rbind(deparse.level, ...) : 
numbers of columns of arguments do not match
7.
stop("numbers of columns of arguments do not match")
6.
rbind(deparse.level, ...)
5.
rbind(edges[!is.na(edges$xend), ], nodes)
4.
unique(rbind(edges[!is.na(edges$xend), ], nodes))
3.
format_fortify(model = model, nodes = nodes, weights = weights, 
arrow.gap = arrow.gap, by = by, scale = scale, stringsAsFactors = stringsAsFactors, 
.list_vertex_attributes_fun = network::list.vertex.attributes, 
.get_vertex_attributes_fun = network::get.vertex.attribute, ...
2.
fortify.network(x, ...)
1.
ggnetwork(network)

I need to work with ggnetwork because I need to use ggrepel, otherwise all nodelabels wildly ooverlap in this network. If you had any tips for me how to make this work, they would be very appreciated!

Thanks a lot!

Upvotes: 2

Views: 76

Answers (0)

Related Questions