datastorm-open / visNetwork

R package, using vis.js library for network visualization
Other
542 stars 127 forks source link

visIgraphLayout: undefined columns selected #452

Open nick-youngblut opened 1 year ago

nick-youngblut commented 1 year ago

Regardless of the layout that I set for visIgraphLayout(), I get the following error:

Error in `[.data.frame`(graph$x$nodes, , c("id", setdiff(names(graph$x$nodes), : 
undefined columns selected
8. stop("undefined columns selected")
7. `[.data.frame`(graph$x$nodes, , c("id", setdiff(names(graph$x$nodes), 
"id")))
6. graph$x$nodes[, c("id", setdiff(names(graph$x$nodes), "id"))]
5. igraph::graph_from_data_frame(graph$x$edges[, c("from", "to")], 
directed = TRUE, vertices = graph$x$nodes[, c("id", setdiff(names(graph$x$nodes), 
"id"))])
4. visIgraphLayout(., layout = "layout_nicely")
3. visNetwork(nodes, edges, width = "100%") %>% visPhysics(stabilization = FALSE) %>% 
visEdges(smooth = FALSE) %>% visIgraphLayout(layout = "layout_nicely")

It appears to be some issue with the graph structure that only comes into play when I use visIgraphLayout() with visNetwork()

sessionInfo

R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] aws.signature_0.6.0   aws.s3_0.3.21         httr_1.4.4            visNetwork_2.1.2      tidygraph_1.2.2      
 [6] styler_1.8.1          lintr_3.0.2           languageserver_0.3.14 ggrepel_0.9.2         ggtree_3.6.2         
[11] tidytree_0.4.1        treeio_1.22.0         ape_5.6-2             data.tree_1.0.0       lubridate_1.9.0      
[16] timechange_0.1.1      memoise_2.0.1         tidytable_0.9.1       data.table_1.14.6     plotly_4.10.1        
[21] ggplot2_3.4.0         reactable_0.3.0       collapsibleTree_0.1.7 shinyTree_0.2.7       shinyWidgets_0.7.5   
[26] shinycssloaders_1.0.0 shinyBS_0.61.1        jsonlite_1.8.3        paws_0.1.12           dbplyr_2.2.1         
[31] dplyr_1.0.10          DBI_1.1.3             shiny_1.7.3           RPostgres_1.4.4      

loaded via a namespace (and not attached):
 [1] colorspace_2.0-3              ellipsis_0.3.2                rprojroot_2.0.3               base64enc_0.1-3              
 [5] aplot_0.1.8                   paws.security.identity_0.1.12 farver_2.1.1                  graphlayouts_0.8.4           
 [9] remotes_2.4.2                 bit64_4.0.5                   fansi_1.0.3                   xml2_1.3.3                   
[13] R.methodsS3_1.8.2             cachem_1.0.6                  polyclip_1.10-4               pkgload_1.3.2                
[17] R.oo_1.25.0                   ggforce_0.4.1                 BiocManager_1.30.19           compiler_4.2.1               
[21] Matrix_1.4-1                  assertthat_0.2.1              fastmap_1.1.0                 lazyeval_0.2.2               
[25] cli_3.4.1                     tweenr_2.0.2                  later_1.3.0                   htmltools_0.5.3              
[29] tools_4.2.1                   igraph_1.3.5                  gtable_0.3.1                  glue_1.6.2                   
[33] Rcpp_1.0.9                    jquerylib_0.1.4               vctrs_0.5.1                   nlme_3.1-157                 
[37] crosstalk_1.2.0               ggraph_2.1.0                  paws.common_0.5.1             stringr_1.4.1                
[41] ps_1.7.2                      mime_0.12                     lifecycle_1.0.3               renv_0.15.5                  
[45] MASS_7.3-57                   scales_1.2.1                  hms_1.1.2                     promises_1.2.0.1             
[49] rex_1.2.1                     parallel_4.2.1                yaml_2.3.6                    curl_4.3.3                   
[53] gridExtra_2.3                 ggfun_0.0.9                   yulab.utils_0.0.5             sass_0.4.2                   
[57] stringi_1.7.8                 desc_1.4.2                    cyclocomp_1.1.0               rlang_1.0.6                  
[61] pkgconfig_2.0.3               lattice_0.20-45               purrr_0.3.5                   patchwork_1.1.2              
[65] htmlwidgets_1.5.4             labeling_0.4.2                bit_4.0.5                     tidyselect_1.2.0             
[69] processx_3.8.0                magrittr_2.0.3                R6_2.5.1                      generics_0.1.3               
[73] pillar_1.8.1                  withr_2.5.0                   tibble_3.1.8                  crayon_1.5.2                 
[77] utf8_1.2.2                    viridis_0.6.2                 grid_4.2.1                    reactR_0.4.4                 
[81] blob_1.2.3                    callr_3.7.3                   digest_0.6.30                 xtable_1.8-4                 
[85] R.cache_0.16.0                tidyr_1.2.1                   httpuv_1.6.6                  gridGraphics_0.5-1           
[89] R.utils_2.12.2                munsell_0.5.0                 viridisLite_0.4.1             ggplotify_0.1.0              
[93] bslib_0.4.1   
nick-youngblut commented 1 year ago

I didn't have rownames for the nodes table (format = tibble), which caused the error. It might be best to check that there are row numbers for the input nodes table.