Skip to content

Commit

Permalink
#3 Updated summary.egor taking design weights into accout, when calcu…
Browse files Browse the repository at this point in the history
…lating average netzsize and average density.
  • Loading branch information
tilltnet committed May 20, 2017
1 parent de4a868 commit 6734682
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/egor.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,20 @@ summary.egor <- function(object, ...) {
nc <- nrow(object)

# Average netsize
nts <- sum(unlist(lapply(object$.alters, FUN = NROW))) / nc
nts <- survey::svymean(unlist(lapply(object$.alters, FUN = NROW)),
ego.design(object))

# Average density
if(".alter_ties" %in% names(object)) dens <- sum(ego_density(object), na.rm = T) / nc else dens <- NULL
if(".alter_ties" %in% names(object))
dens <- survey::svymean(ego_density(object), ego.design(object))
else
dens <- NULL

cat(paste(nc, "Egos/ Ego Networks", "\nAverage Netsize", nts, "\n"))
if(!is.null(dens)) cat(paste("Average Density", dens))

# Meta Data
cat("Ego sampling design:\n")
cat("\nEgo sampling design:\n")
#' @importFrom utils capture.output
writeLines(paste(" ", capture.output(print(attr(object, "ego.design"))), sep=""))

Expand Down

0 comments on commit 6734682

Please sign in to comment.