简体   繁体   中英

R-program - igraph package error

I have encountered an error message in an R Program (see code\\details below) when I tried to use igraph library in my Xubuntu VM. This problem did not happen before . Everything was working just fine.

It started very recently when I was trying to re-set-up R\\igraph in another new VM(Xubuntu) of mine.

Can anybody give me any kind of advice regarding how to fix this problem?

Below are the Details -

Error Message -

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

How I installed 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')"

My R - Program

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)

I thought I will share the final solution that seems to work for me. I digged down a bit and upon some analysis , I found out the below. The error seems to be with the igraph version - V1.0. The code statement in above R - program

l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)

errors out in igraph V1.0.

The R-igraph package is re-written - and thereby some of the functions\\network algorithms from older version is replaced\\re-coded\\modified in newer igraph version - 1.0 onwards. So I reverted back to an older igraph package (0.7.1) and now I am no more facing the issue. And my R-program seems to work fine. Below are the commands to revert to an older igraph package 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM