vendredi 25 août 2017

R create Random Networks according data frame

I have a data frame "ref.df" that has info about 12 networks. I want to create 100 random networks for each subject according their node and edge numbers.

I've tried this code but it didn't work well:

    library(igraph)

    random.networks <- list()

    for(i in ref.df$subject){
              cat("...")
              for( j in 1:100){
              random.networks[[j]] <- sample_gnm(n=ref.df$node,m=ref.df$edge, directed = TRUE, loops = FALSE)
              }
              cat(i,"\n")
            }

Thanks for your time and advice in advance.

You can reproduce my data frame:

ref.df <- data.frame(subject=c("Civil.Liberties","Foreign.Policy","Women.s.Rights","Workers..Rights",
                           "Political.Polarisation","Kurdish.Peace.Process","Parallel.State",
                           "HDP.Election.Slogans","Related.With.Election","CHP.Election.Slogans",
                           "AKP.Election.Slogans","MHP.Election.Slogans"),
                 group=c(298,1150,474,2522,0,2570,718,2736,0,1661,2175,1460),
                 mod=c(0.77,0.73,0.84,0.78,0,0.72,0.66,0.62,0,0.68,0.76,0.66),
                 node=c(13524,68792,21925,87094,195678,98008,28499,93024,201342,61539,91640,63035),
                 edge=c(18694,183932,27120,143032,710044,249267,108352,255615,579919,17590,3313147,213367))




Aucun commentaire:

Enregistrer un commentaire