[R] Social Networks - how to get the same network layout every time when I plot the network?

jim holtman jholtman at gmail.com
Wed Jan 7 01:34:50 CET 2009


If you want the same network each time, then set the random seed to
the same value:

n<-6
dat <- rbinom(n*(n-1)/2,1,.6)
net<-diag(n)
net[lower.tri(net)] <- dat
net[upper.tri(net)] <- t( net )[upper.tri(net)]
net #the network
library(network)
g<-network(net,directed=FALSE)
set.seed(1)
plot.network(g)
set.seed(1)
plot.network(g)


On Tue, Jan 6, 2009 at 4:45 PM, Despina Stefan
<Despina.Stefan at genmills.com> wrote:
> Hi,
> I am using the function plot.network from the network library. However, I noticed that every time when I use the function I get a different layout (the network is rotated?). I would like to get the exact same picture every time when I use the function. Is that possible (maybe set a seed or some layout parameters?)? How?
> Here is an example:
>
> n<-6
> dat <- rbinom(n*(n-1)/2,1,.6)
> net<-diag(n)
> net[lower.tri(net)] <- dat
> net[upper.tri(net)] <- t( net )[upper.tri(net)]
> net #the network
> library(network)
> g<-network(net,directed=FALSE)
> plot.network(g)
>
> and if I run
>
> plot.network(g)
>
> again, I get the same network (dah!) but rotated.
> Any suggestions?
> Thank you,
> Despina
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list