I’ve followed through the example to create ego-size and alter-density measures. When I view the results in R console, I could see the ego-vertex as well as these attributes on the right column. However, when I try to use cbind or as.data.frame to output my result, I only have the ego-size and alter-density outcomes, without the ego vertex. When I check the # of columns of these results, it also shows up as 1 instead of 2 (as if the ego vertex column isn’t a real column).
Could anyone please indicate how I could extract ego-vertex info when I export my data? Thank you very much!
#Generate a sample network
g<-rgraph(10,tp=1.5/9)
#Extract some ego nets
g.in<-ego.extract(g,neighborhood="in")
g.out<-ego.extract(g,neighborhood="out")
g.comb<-ego.extract(g,neighborhood="in")
#View some networks
g.comb
#Compare ego net size with degree
all(sapply(g.in,NROW)==degree(g,cmode="indegree")+1) #TRUE
all(sapply(g.out,NROW)==degree(g,cmode="outdegree")+1) #TRUE
all(sapply(g.comb,NROW)==degree(g)/2+1) #Usually FALSE!
#Calculate egocentric network density
ego.size<-sapply(g.comb,NROW)
if(any(ego.size>2))
sapply(g.comb[ego.size>2],function(x){gden(x[-1,-1])})