statnet / ergm.ego

Fit, Simulate and Diagnose Exponential-Family Random Graph Models to Egocentrically Sampled Network Data https://statnet.org
Other
14 stars 4 forks source link

degreedist.egodata fails for non-numeric egoIDs (or named factors) #18

Closed marioangst closed 6 years ago

marioangst commented 6 years ago

Line 58 in https://github.com/statnet/ergm.ego/blob/master/R/degreedist.R: degtable[as.numeric(names(table(egodata$alters[egoIDcol])))] <- table(egodata$alters[egoIDcol])

is problematic if names(table(egodata$alters[egoIDcol])) are not numbers as this produces NAs (if egoIDs are given as Not a big problem as the "as.numeric" can be easily removed in this case, but an update would be appreciated.

A minimal reproducible example:

egonet <- as.egodata.data.frame(object = data.frame(egoid = c("A","B","C")), alters = data.frame(egoid = c("A","A","B","C","C","C")), egoIDcol = "egoid") degreedist.egodata(egonet)

krivit commented 6 years ago

Thanks for the report. It looks like it's working in the current master branch. Can you try installing that and seeing if you can reproduce the problem?

krivit commented 6 years ago

Since I can't reproduce the problem, I am going to assume that it's been fixed in master.