Ok, the problem seems simpler than I thought. It works well if omit two lines: y_s[,1] <- V(y)$name[y_s[,1]] y_s[,2] <- V(y)$name[y_s[,2]]
It seems melt creates a data.frame (unlike what it did two years ago?) Joe On Tue, Aug 27, 2013 at 12:35 AM, Joseph J. Bakker <joe.st...@gmail.com>wrote: > Two years ago, as shown in the script at the end, I created shortestpaths >> using Igraph, then using Melt in Reshape2 I converted the the resulting >> matrix into >> three column vectors - "vertex1", "vertex2", "shortestpath". It worked >> then. > > > >> However, in the meantime I have installed new versions of R and these two >> libraries. Creating column vectors with names of rows and columns don't >> work anymore; the name columns are mostly blank. Could anyone suggest a >> solution, preferably not dependent on a library, given my bad experience >> with Reshape2? > > > > >> Below is the original code >> >> #code for generating shortest path matrix and creating a 3 columns >> from an igraph graph object "y" >> y_s<-shortest.paths(y, weights = NULL) >> y_s <- melt(y_s)[c(upper.tri(y_s)),] >> y_s[,1] <- V(y)$name[y_s[,1]] >> y_s[,2] <- V(y)$name[y_s[,2]] >> names(y_s)<-c("vertex1", "vertex2", "shortestpath") >> >> >> Best regards, >> Joe. >> > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.