Closed chrismlarson closed 5 years ago
I am having the same issue. This also extends to the use of ggnetwork() to fortify a network map for ggplot2.
Others seem to be experiencing the error as well. Here is a related stackoverflow question.
Any suggestions on how to correct this?
I am having the same issue.
ggnet2(net2, node.size=6, node.color="black", edge.size=1, edge.color="grey") Error: Each variable must be a 1d atomic vector or list. Problem variables: 'x', 'y', 'xend', 'yend'
same here
Hi Francois, would you comment on this issue. It seems everyone having the same problem. Please look at this and suggest a solution. Thanks!!
Also getting the same issue - anyone stumble on a solution? Thanks!
I'm on a fresh machine and I'm not seeing this anymore. But I think playing around with the order you load the libraries may help... There's got to be a conflict in there somewhere.
> library(GGally)
> library(network)
> library(sna)
> library(ggplot2)
Hi Francois.
Would you be able to provide an update on this issue? The problem still persists.
set.seed(2017);
net <- network(rgraph(20, mode = "graph", tprob = 0.5), directed = FALSE);
network.vertex.names(net) = letters[1:10];
ggnet2(net);
Error: Columns `x`, `y`, `xend`, `yend` must be 1d atomic vectors or lists
Unfortunately this seems to completely break ggnet2
.
For what it's worth, here's my sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] scales_0.5.0.9000 ggplot2_2.2.1.9000 sna_2.4
[4] statnet.common_4.0.0 network_1.13.0 GGally_1.3.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 reshape_0.8.7 grid_3.4.0 plyr_1.8.4
[5] gtable_0.2.0 rlang_0.1.2 lazyeval_0.2.1 RColorBrewer_1.1-2
[9] tools_3.4.0 munsell_0.4.3 compiler_3.4.0 colorspace_1.3-2
[13] tibble_1.3.4
I was able to use this package succesfully until this week when this error started appearing -- has anyone figured out how to deal with it?
For some reason, x, y, xend, and yend are matrices. (using a ggnetwork-ified df) I dealt with it like this: df_net %>% purrr::map_df(~if (is.matrix(.x)) as.double(.x) else .x)
I think I've found a solution for the issue, at least on my machine. I'm running R 3.4.3 on Win 10, but this is probably not platform-related.
Until now I've had the CRAN version of GGally
installed, along with network
and sna
, just as mentioned in the example, and this setup threw the exact same error that a lot of people mentioned above. I was confused as the original network
object doesn't even have members like x
, xend
, etc. It turned out that these are in fact members of the ggnetwork
object, which is created invisibly during the command ggnet()
. (ggnetwork vignette).
So I've tried installing ggnetwork: install.packages("ggnetwork")
along with the source version of ggnet
(devtools::install_github("briatte/ggnet")
).
ggnetwork was installed succesfully, but the package couldn't be loaded because it said that ggplot2 is not installed (which I've found strange because it's a package that I use on a daily basis as part of the tidyverse
library).
ggnet installation failed for some reason related to packages being already loaded.
I've restarted the R session, tried loading ggnetwork again, which again failed for lack of ggplot2, so I installed ggplot2. I tried once again installing ggnet from source, (this time before any packages were loaded) and it worked.
So, to sum it up: After restarting the R session:
install.packages("ggnetwork")
install.packages("ggplot2")
devtools::install_github("briatte/ggnet")
I don't know exactly which step did it, but afterwards the example script produced a graph plot, just as it was supposed to:
library(ggnetwork)
library(network)
library(sna)
library(ggnet)
net = rgraph(10, mode = "graph", tprob = 0.5)
net = network(net, directed = FALSE)
network.vertex.names(net) = letters[1:10]
ggnet2(net)
@zslehoczky Confirmed to work here aswell. So this seems to have something to do with the order by which packages are loaded and thus conflicting function names across namespaces. Always a good idea to specifically call functions from their correct packages by package::function
...
Confirmed to work as well in vignette "examples-from-paper.Rmd" of package ggCompNet
.
After reinstalling as per @zslehoczky, the packages in this order:
## pre-load
library(ggnetwork)
library(network)
library(sna)
library(GGally)
library(geomnet)
library(igraph)
Dear all ~
Sorry for not answering this thread earlier.
As my StackOverflow answer says, the issue you were facing back then seems to be related either to what tibble
accepts as a 'tidy' data frame. This would have affected 'tidyverse' packages as you reported back then.
The issue seems to be solved by now, given that I can run the code below (taken from the StackOverflow question mentioned above) either with or without the tidyverse loaded.
library(dplyr)
library(nycflights13)
library(igraph)
library(sna)
library(ggnetwork)
df_edges <- flights %>% group_by(origin, dest) %>% summarize(weight = n())
net <- graph.data.frame(df_edges, directed = T)
V(net)$degree <- centralization.degree(net)$res
df_net <- ggnetwork(net, layout = "fruchtermanreingold", weights = "weight", niter = 5000)
ggplot(df_net, aes(x = x, y = y, xend = xend, yend = yend)) +
geom_edges(size = 0.4, alpha = 0.25) +
geom_nodes(aes(size = degree, text = vertex.names)) +
ggtitle("Network Graph of U.S. Flights Outbound from NYC in 2013") +
theme_blank()
In all cases, apologies again for leaving this issue unresolved by then, but I do remember that, after the ggplot2 v2.0.0 update and when the tidyverse arrived, things were very much in flux and breaking all around. Namespace conflicts are now better handled by R (and the tidyverse), so I hope that there won't be another of these threads in the future.
I'm trying to follow the examples here: https://briatte.github.io/ggnet/
And I'm getting this error:
Is there something wrong with my environment? I tried starting clean, but I'm rather new to R.
The code I'm using: