R 程序 - igraph 包错误
R-program - igraph package error
当我尝试在我的 Xubuntu VM 中使用 igraph 库时,我在 R 程序中遇到了一条错误消息(请参阅下面的 code\details)。这个问题以前没有发生过。一切正常。
它是最近开始的,当时我试图在我的另一个新 VM (Xubuntu) 中重新设置 R\igraph。
任何人都可以给我任何关于如何解决这个问题的建议吗?
详情如下 -
错误信息-
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
Loading required package: methods
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
我如何安装 R Base 和 Igraph -
sudo apt-get -y install r-base
sudo echo "r <- getOption('repos'); r['CRAN'] <- 'http://cran.us.r- project.org'; options(repos = r);" > ~/.Rprofile
sudo Rscript -e "install.packages('ggplot2')"
sudo Rscript -e "install.packages('plyr')"
sudo Rscript -e "install.packages('reshape2')"
sudo Rscript -e "install.packages('igraph')"
sudo Rscript -e "install.packages('doBy')"
sudo Rscript -e "install.packages('stargazer')"
我的 R - 程序
library(igraph)
g <- read.graph("DataForImage.net", format="pajek")
g <- delete.vertices(g,which(degree(g)<1))
jpeg(filename = "Image1.jpg", width = 2000, height = 2000,
units = "px", pointsize = 10, bg = "white",
res = NA)
g <- simplify(g)
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
l <- layout.norm(l, -1,1, -1,1)
fcs <- fastgreedy.community(simplify(as.undirected(g)))
Q <- round(max(fcs$modularity), 3)
fcs <- community.to.membership(g, fcs$merges, steps=which.max(fcs$modularity)-1 )
plot(g, layout=l,vertex.shape="circle", vertex.size=2, vertex.label=NA, vertex.color="black",
vertex.frame.color="black", edge.width=5,
rescale=FALSE, xlim=range(l[,1]), ylim=range(l[,2]),
main="")
results <- read.table("detailTotals.csv", header=TRUE, sep=",")
jpeg(filename = "Image2.jpg", width = 2000, height = 2000,
units = "px", pointsize = 50, bg = "white",
res = NA)
plot(results$SetLineTotal, results$SetCount, main="Set Analysis",
xlab="Set Lines", ylab="Set Counts", col="black", bg="black", pch=21, cex=1)
grid(nx = 50, ny = 50, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
我想我会分享似乎对我有用的最终解决方案。
我深入挖掘了一下,经过一些分析,我发现了以下内容。
错误似乎与 igraph 版本有关 - V1.0。上面 R 中的代码语句 - program
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
igraph V1.0 中出现错误。
R-igraph 包被重写 - 因此旧版本的一些 functions\network 算法在较新的 igraph 版本中是 replaced\re-coded\modified - 1.0 以上。
所以我恢复到旧的 igraph 包 (0.7.1),现在我不再面临这个问题。我的 R 程序似乎运行良好。
以下是恢复到旧 igraph 包 0.7.1
的命令
wget http://cran.r-project.org/src/contrib/Archive/igraph/igraph_0.7.1.tar.gz
sudo R CMD INSTALL igraph_0.7.1.tar.gz
当我尝试在我的 Xubuntu VM 中使用 igraph 库时,我在 R 程序中遇到了一条错误消息(请参阅下面的 code\details)。这个问题以前没有发生过。一切正常。
它是最近开始的,当时我试图在我的另一个新 VM (Xubuntu) 中重新设置 R\igraph。
任何人都可以给我任何关于如何解决这个问题的建议吗?
详情如下 -
错误信息-
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
Loading required package: methods
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
我如何安装 R Base 和 Igraph -
sudo apt-get -y install r-base
sudo echo "r <- getOption('repos'); r['CRAN'] <- 'http://cran.us.r- project.org'; options(repos = r);" > ~/.Rprofile
sudo Rscript -e "install.packages('ggplot2')"
sudo Rscript -e "install.packages('plyr')"
sudo Rscript -e "install.packages('reshape2')"
sudo Rscript -e "install.packages('igraph')"
sudo Rscript -e "install.packages('doBy')"
sudo Rscript -e "install.packages('stargazer')"
我的 R - 程序
library(igraph)
g <- read.graph("DataForImage.net", format="pajek")
g <- delete.vertices(g,which(degree(g)<1))
jpeg(filename = "Image1.jpg", width = 2000, height = 2000,
units = "px", pointsize = 10, bg = "white",
res = NA)
g <- simplify(g)
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
l <- layout.norm(l, -1,1, -1,1)
fcs <- fastgreedy.community(simplify(as.undirected(g)))
Q <- round(max(fcs$modularity), 3)
fcs <- community.to.membership(g, fcs$merges, steps=which.max(fcs$modularity)-1 )
plot(g, layout=l,vertex.shape="circle", vertex.size=2, vertex.label=NA, vertex.color="black",
vertex.frame.color="black", edge.width=5,
rescale=FALSE, xlim=range(l[,1]), ylim=range(l[,2]),
main="")
results <- read.table("detailTotals.csv", header=TRUE, sep=",")
jpeg(filename = "Image2.jpg", width = 2000, height = 2000,
units = "px", pointsize = 50, bg = "white",
res = NA)
plot(results$SetLineTotal, results$SetCount, main="Set Analysis",
xlab="Set Lines", ylab="Set Counts", col="black", bg="black", pch=21, cex=1)
grid(nx = 50, ny = 50, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
我想我会分享似乎对我有用的最终解决方案。 我深入挖掘了一下,经过一些分析,我发现了以下内容。 错误似乎与 igraph 版本有关 - V1.0。上面 R 中的代码语句 - program
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
igraph V1.0 中出现错误。
R-igraph 包被重写 - 因此旧版本的一些 functions\network 算法在较新的 igraph 版本中是 replaced\re-coded\modified - 1.0 以上。 所以我恢复到旧的 igraph 包 (0.7.1),现在我不再面临这个问题。我的 R 程序似乎运行良好。 以下是恢复到旧 igraph 包 0.7.1
的命令wget http://cran.r-project.org/src/contrib/Archive/igraph/igraph_0.7.1.tar.gz
sudo R CMD INSTALL igraph_0.7.1.tar.gz