Network of cities with distances as edges length

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Network of cities with distances as edges length

edoardo baldoni
Hello,

I am building a network using a distance matrix with the package 'network'

I want to create a network with cities as vertices and with the length of
the edges between them that reflects their distances.

How can I ? All I tried did not work

I tried the following code but the result is a graph with curved edges that
do not reflect distances between cities. It is not what I want.

nDist2 = network(Dist2,directed=TRUE)
set.edge.value(nDist2,'Km',Dist2)
plot.network(nDist2,label=network.vertex.names(nDist2),
edge.len=get.edge.value(nDist2,'Km')/10000,uselen=T)



My data matrix (Dist2) is:


Oxford Hamburg Dublin Hoersholm Oslo  Oxford 0 786.4 382.97 1013.98 1176.23
Hamburg 786.4 0 1077.74 305.9 710.03  Dublin 382.97 1077.74 0 1240.48
1268.59  Hoersholm 1013.98 305.9 1240.48 0 460.72  Oslo 1176.23 710.03
1268.59 460.72 0

Thanks

Edoardo

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.