Hi, As a beginner in R, I need some help on a programming problem which, I guess, will seem trivial to you:
I am doing some Network analysis in which I need to calculate some metrics for all the weeks I have (each week the network evolves in terms of number of nodes etc...) For exemple, I need to calculate the degrees of the nodes each weak, and to repeat it in a loop for all the weeks ( for 265 weeks). So for each weak, I want to write a vector containing the degrees of every nodes ( a 1*300 vector for 300 nodes for example). At the end, I will have 265 vectors with dimensions: the number of nodes each week. In the following code I tried, the program just write one vector called indeg[i] corresponding to the last week, where I would like indeg1, indeg2,...,indeg265. Rm(list()) 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 indeg<-degree(g) #degree calculation for each node of the network write(indeg, "indeg[i]".txt, sep="\n") } Is there some obvious mistake in my program, or does anyone have a solution to do this? Thanks a lot , Yanis El Omari Trainee - Economic Research European Securities and Markets Authority (ESMA) 103, rue de Grenelle, 75007 Paris - France Tel: + 33 1 58 36 51 37 Email : yanis.elom...@esma.europa.eu<mailto:yanis.elom...@esma.europa.eu> [[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.