Create a factor variable for the different age categories, see cut().
Then use as.integer() on the factor variable and index a vector of
node sizes with it. E.g.
g <- graph.ring(10)
V(g)$age <- sample(20:78, vcount(g), replace=TRUE)
V(g)$agecat <- cut(V(g)$age, breaks = c(20,35,50,65,78))
V(g)$size <- c(10,15,20,25)[ V(g)$agecat ]
plot(g, layout=layout.circle)
Best,
Gabor
On Wed, Aug 10, 2011 at 1:38 PM, Gaitan, Andreea
<andreea.gaitan10 at imperial.ac.uk> wrote:> Hi,
>
> I'm working on some social networks and I managed to create the graphs
with labels and edges weight, but I would also like to change the size of the
vertices according to the age of the persons in the network and the shape
according to the gender. Now for the age, I have people with ages between 20 and
78, and I would like to have 4 categories (sizes): 20-35, 36-50, 50-65, >65.
I have entered the ages as attributes of the vertices from a table, so they are
included in the graph, but how do I change the size in the plot? And the same
for gender with different shapes (circle and square maybe).
>
> Thanks in advance and regards,
> Andreea.
>
> ? ? ? ?[[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.
>
--
Gabor Csardi <csardi at rmki.kfki.hu>? ?? MTA KFKI RMKI