[R] help

Gábor Csárdi csardi at rmki.kfki.hu
Wed Aug 22 21:27:48 CEST 2012


Hi,

the thing is, you didn't really have any questions in your email. What
is the problem with your code? Is it not giving the expected results?
More below.

On Wed, Aug 22, 2012 at 8:31 AM, Yanis El Omari
<yanis.elomari at esma.europa.eu> wrote:
[...]
> Rm(list())

What is this this supposed to do? Do you mean 'rm(list=ls())' ?

> library(R.matlab)
> library(igraph)
> path<-("D:/adj_matrices/nonweighted_GOVSOV")
> setwd(path)
> vector.files<-paste("nonweighted_GOVSOV",1:265, ".mat",sep="")
> dat<-list()
>
> for(i in 1:265) {
> dat[[i]] <-readMat(file.path(path,vector.files[i]))
> adj<-do.call(rbind, dat[[i]])
> g<-graph.adjacency(adj, mode=c("directed"), weighted=T) # the graph object of the network
>
> a<-length(V(g))                                         #the number of nodes
>
> indeg<-rep(0,a)                                         #the vector where I want to write the degree of each node for week i

The above two lines are not needed, you can remove them.

> indeg<-degree(g)                                                                                                                 #degree calculation for each node of the network
>
> write(indeg, "indeg[i]".txt, sep="\n")

This is probably wrong, the results are written to a file named
"indeg[i].txt", I think you want something like

write(indeg, sprintf("indeg[%i].txt", i), sep="\n")

> }
>
>
> Is there some obvious mistake in my program, or does anyone have a solution to do this?

Maybe, but what is your problem with it? (Apart from the incorrect
naming of the output files.)

Gabor

[...]

-- 
Gabor Csardi <csardi at rmki.kfki.hu>     MTA KFKI RMKI




More information about the R-help mailing list