Dear users,
I am stucked with a programming problem: I am trying to download a squared
adjacency matrix from matlab with only 0 or 1. Doing it without a loop at
first, I get an error message that is, I think, related to the
"mat_adj<-readMat(pathnames_adj)" line. Did anybodz encouter already that
problem? If so, do I need to change anything in my code in order it not to be
recurrent? If I run the code a second time, it works fine, but this does not
help me, as I try to set up a loop for 265 matlab adj matrix, each number
representing a specific week and the purpose being to have metrics from igraph
being generated over the 265 weeks.
Thank you
CODE to read the file:
rm(list=ls())
library(R.matlab)
path<-setwd("V:/2012/nonweighted_GOVSOV")
pattern_adj<-sprintf("weightmatrix1.mat")
pathnames_adj<-list.files(pattern=pattern_adj,path=path,full.names=T)
cat("Reading MAT file: ", basename(pathnames_adj), "\n", sep="")
mat_adj<-readMat(pathnames_adj)
adj<-do.call(rbind,mat_adj)
library(igraph)
g<-graph.adjacency(adj, mode=c("directed"), weighted=T)
_______________________________________________________________________
R RESPONSE:
> path<-setwd("V:/2012/nonweighted_GOVSOV")
> pattern_adj<-sprintf("weightmatrix1.mat")
> pathnames_adj<-list.files(pattern=pattern_adj,path=path,full.names=T)
> cat("Reading MAT file: ", basename(pathnames_adj), "\n", sep="")
Reading MAT file:
> mat_adj<-readMat(pathnames_adj)
Error in file(con, open = "rb") : invalid 'description' argument
> adj<-do.call(rbind,mat_adj)
Error in do.call(rbind, mat_adj) : object 'mat_adj' not found
> library(igraph)
Attaching package: ‘igraph’
The following object(s) are masked from ‘package:R.oo’:
hierarchy
> g<-graph.adjacency(adj, mode=c("directed"), weighted=T)
Error in inherits(adjmatrix, "Matrix") : object 'adj' not found
______________________________________________
[email protected] 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.