我正在尝试建立贝叶斯网络模型。但是,我无法安装合适的软件包。尝试使用gRainbnlearnRgraphviz进行绘图。我已经在R 2.15和3.2中尝试过

以下是错误消息:

library(gRain)
Loading required package: gRbase
Loading required package: graph
Error: package ‘graph’ could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
  there is no package called ‘graph’

> install.packages("graph")
Warning message:
package ‘graph’ is not available (for R version 2.15.3)

与R 3.2.1相同
> install.packages("graph")
(as ‘lib’ is unspecified)
Warning message:
package ‘graph’ is not available (for R version 3.2.1)


> install.packages("Rgraphviz")
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning messages:
1: In open.connection(con, "r") : unable to resolve 'cran.r-project.org'
2: package ‘Rgraphviz’ is not available (for R version 3.2.1)

> install.packages("Rgraphviz")
(as ‘lib’ is unspecified)
Warning message:
package ‘Rgraphviz’ is not available (for R version 2.15.3)

该模型的其他信息

1)变量数-17
2)变量类型-离散/连续

最佳答案

软件包graphRBGLRgraphviz不在CRAN上,而是在bioconductor上。

要安装这些软件包,请执行

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install(c("graph", "RBGL", "Rgraphviz"))

然后以通常的方式从CRAN安装软件包:
install.packages("gRain", dependencies=TRUE)

另请参见 gRain installation instructions

关于r - 带R的贝叶斯网络,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31252102/

10-12 20:08