# Set network with two vertex attributes and check distribution
nw <- network.initialize(100)
nw %v% "race" <- rep(0:1, each=50)
nw %v% "sex" <- c(rep("M", 10), rep("F", 90))
prop.table(table(nw %v% "race"))
prop.table(table(nw %v% "sex"))
# Formation formula uses both attributes
formation <- ~ edges + nodematch("race") + nodematch("sex")
# Need to get existing proportions of those two terms first
nm.attr <- get.nodematch.attributes(nw, formation)
# Now add 50 more nodes, and set the new attributes in proportion
add.vertices(nw, nv=50)
nw <- set.nodematch.attributes(nw, nm.attr, new.nodes=101:150)
# Some random variation due to sampling new node values
prop.table(table(nw %v% "race"))
prop.table(table(nw %v% "sex"))
Run the code above in your browser using DataLab