Closed instantkaffee closed 5 years ago
Hello @briatte , when do you think that a fix becomes available?
@instantkaffee I am running into the same problem, did you ever find a work around?
@martinritchie No, I was hoping for a fix from @briatte
I'm also looking for a fix.
I think I have a fix, I will submit a pull request tomorrow.
@martinritchie is your fix accepted?
Sorry for the slow reply. I noticed that there is already a pull requuest that fixes this issue. Have a look, it is quite easy to implement yourself whilst you wait for the pull to be approved.
This issue still looks alive, despite PR #20. Package might need PR #24 after all.
Interestingly, issue occurs only with igraph
:
# remotes::install_github("briatte/ggnetwork")
library(ggnetwork)
#> Loading required package: ggplot2
# 2-node, 1-edge network
g <- igraph::random.graph.game(n = 2, p.or.m = 1)
# fails
ggnetwork(g)
#> Error in value[[3L]](cond): could not coerce object to a network: see ?ggnetwork for help
# fails
ggnetwork:::fortify.igraph(g)
#> Error in if (nrow(edges[, 1:2]) > nrow(unique(edges[, 1:2]))) {: argument is of length zero
# ... but if converted to just a matrix
m <- as.matrix(igraph::as_adjacency_matrix(g))
# works
ggnetwork(m)
#> x y na.x vertex.names xend yend na.y
#> 1 1 0 FALSE 1 1.00000000 0.00000000 NA
#> 2 0 1 FALSE 2 0.00000000 1.00000000 NA
#> 3 0 1 FALSE 2 0.98232233 0.01767767 FALSE
#> 4 1 0 FALSE 1 0.01767767 0.98232233 FALSE
# works
ggplot(ggnetwork(m), aes(x, y, xend = xend, yend = yend)) +
geom_nodes() +
geom_edges()
# ... same if converted to network
n <- network::network(m, directed = FALSE)
# works
ggnetwork(n)
#> x y na.x vertex.names xend yend na.y
#> 1 0 1 FALSE 1 0 1 NA
#> 2 1 0 FALSE 2 1 0 NA
#> 21 1 0 FALSE 2 0 1 FALSE
# works
ggnetwork:::fortify.network(n)
#> x y na.x vertex.names xend yend na.y
#> 1 0 1 FALSE 1 0 1 NA
#> 2 1 0 FALSE 2 1 0 NA
#> 21 1 0 FALSE 2 0 1 FALSE
# works
ggplot(ggnetwork(n), aes(x, y, xend = xend, yend = yend)) +
geom_nodes() +
geom_edges()
Created on 2019-07-27 by the reprex package (v0.3.0)
All apologies for the long wait one this issue… !
Hi!
I just got this error with version 0.5.1. Was this resolved?
Thanks Komal
Hi @komalsrathi
Yes, that issue is solved, but in the development branch so far -- please reinstall the package from GitHub to solve the issue:
remotes:install_github("briatte/ggnetwork")
CRAN submission is late but will happen soon.
throughs in Version 0.5.1:
I think
g
is a valid Input for ggnetwork. Any fix ?