问题
My igraph library doesn't recognize "graph_from_incidence_matrix() and graph_from_adjacency_matrix()" anymore (Everything else from igraph works fine). I've uninstalled and reinstalled igraph but still no luck. Here is an example:
library(igraph)
inc <- matrix(sample(0:1, 15, repl=TRUE), 3, 5)
colnames(inc) <- letters[1:5]
rownames(inc) <- LETTERS[1:3]
graph_from_incidence_matrix(inc)
Error: could not find function "graph_from_incidence_matrix"
Any help is appreciated. UPDATE: Here is my session info:
`R version 3.1.3 (2015-03-09)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
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 utils datasets methods base
other attached packages:
[1] qgraph_1.3.1 R.matlab_3.2.0 igraph_0.7.1
loaded via a namespace (and not attached):
[1] acepack_1.3-3.3 cluster_2.0.1 colorspace_1.2-6 corpcor_1.6.7
[5] d3Network_0.5.2.1 digest_0.6.8 ellipse_0.3-8 fdrtool_1.2.14
[9] foreign_0.8-63 Formula_1.2-1 ggm_2.3 ggplot2_1.0.1
[13] glasso_1.8 grid_3.1.3 gridExtra_0.9.1 gtable_0.1.2
[17] gtools_3.4.2 Hmisc_3.16-0 huge_1.2.6 jpeg_0.1-8
[21] lattice_0.20-31 latticeExtra_0.6-26 lavaan_0.5-18 magrittr_1.5
[25] MASS_7.3-40 Matrix_1.2-0 matrixcalc_1.0-3 mnormt_1.5-2
[29] munsell_0.4.2 nnet_7.3-9 parallel_3.1.3 pbivnorm_0.6.0
[33] plyr_1.8.2 png_0.1-7 proto_0.3-10 psych_1.5.4
[37] quadprog_1.5-5 R.methodsS3_1.7.0 R.oo_1.19.0 R.utils_2.0.2
[41] RColorBrewer_1.1-2 Rcpp_0.11.6 reshape2_1.4.1 rjson_0.2.15
[45] rpart_4.1-9 scales_0.2.4 sem_3.1-5 sna_2.3-2
[49] splines_3.1.3 stats4_3.1.3 stringi_0.4-1 stringr_1.0.0
[53] survival_2.38-1 tools_3.1.3 whisker_0.3-2 `
回答1:
are you sure you loaded the library correctly? at the moment there is a ' infront of the row
library(igraph)
remove that and run your code again. after the library()-statement you should get something similar to this one:
Attach paket: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
After running the rest of your code I get the following output:
IGRAPH 6798dd1 UN-B 8 6 --
+ attr: type (v/l), name (v/c)
+ edges from 6798dd1 (vertex names):
[1] A--a A--b A--c A--e B--b C--e
来源:https://stackoverflow.com/questions/45892699/r-igraph-graph-from-incidence-matrix-and-graph-from-adjacency-matrix-dont