Facebook networks from Wave 2

– Aditya File in /project/khanna7/Projects/UConnect/UConnect_FB/Wave_2/descriptives

These are visualizations of the Facebook network.

Respondent-Only network

ggnet2(w2.resp.net, size=1, color="seed", palette="Set2")
## Loading required package: sna
## Loading required package: statnet.common
## sna: Tools for Social Network Analysis
## Version 2.4 created on 2016-07-23.
## copyright (c) 2005, Carter T. Butts, University of California-Irvine
##  For citation information, type citation("sna").
##  Type help(package="sna") to get started.
## 
## Attaching package: 'sna'
## The following objects are masked from 'package:igraph':
## 
##     betweenness, bonpow, closeness, components, degree,
##     dyad.census, evcent, hierarchy, is.connected, neighborhood,
##     triad.census
## Loading required package: scales

plot of chunk unnamed-chunk-3

w2_ig_nonresp_10pc <- readRDS("w2_ig_nonresp_10pc.RDS")
w2_ig_nonresp_10pc_net <- asNetwork(w2_ig_nonresp_10pc)
list.vertex.attributes(w2_ig_nonresp_10pc_net)
head(w2_ig_nonresp_10pc_net%v%"vertex.names", 410)

seed_id <- which(substr(w2_ig_nonresp_10pc_net %v% "vertex.names", 1, 4) == "1111")
recruit_id <- which(substr(w2_ig_nonresp_10pc_net %v% "vertex.names", 1, 4) == "2222")
resp_id <- c(seed_id, recruit_id)

w2_ig_nonresp_10pc_net %v% "respondent" <- 0
set.vertex.attribute(w2_ig_nonresp_10pc_net, "respondent", 1, resp_id)
table(w2_ig_nonresp_10pc_net %v% "respondent")
sum(table(w2_ig_nonresp_10pc_net %v% "respondent"))

Network with Respondents and Non-Respondents connected to at least 10% of Respondents

ggnet2(w2_ig_nonresp_10pc_net, size=1, color="respondent", palette="Set2")

plot of chunk unnamed-chunk-5

Network with Respondents and Non-Respondents connected to at least 10% of Respondents

ggnet2(w2_ig_nonresp_10pc_net, size=1, color="respondent", palette="Set2")

plot of chunk unnamed-chunk-6

  net_no_isolates_ids <- which(degree(w2_ig_nonresp_10pc_net, gmode="graph") > 0)


  net_no_isolates <- get.inducedSubgraph(w2_ig_nonresp_10pc_net, 
                                         v=net_no_isolates_ids)

  ggnet2(net_no_isolates, size=1, color="respondent", palette="Set2")

plot of chunk unnamed-chunk-7

  ## change label
  list.vertex.attributes(net_no_isolates)
## [1] "degree"       "na"           "respondent"   "vertex.names"
  no_iso_resp_id <- which(net_no_isolates %v% "respondent" == 1)
  no_iso_nonresp_id <- which(net_no_isolates %v% "respondent" == 0)

  net_no_isolates %v% "nodes" <- c("respondents")
  set.vertex.attribute(net_no_isolates,"nodes", "nonrespondents", v=no_iso_nonresp_id)  
  table(net_no_isolates %v% "nodes")
## 
## nonrespondents    respondents 
##            744            400
  coord1 <- ggnet2(net_no_isolates, size=1, color="nodes", palette="Set2")
mat <- (coord1$data)

coords <- cbind(mat$x, mat$y)
ggnet2(net_no_isolates, size=1, color="nodes", palette="Set2", mode=coords)

plot of chunk unnamed-chunk-7

## Show influencers in network diagram
set.vertex.attribute(net_no_isolates, "network_position", "non_influencer")
load("../results_w2_from_igraph/names_of_influencers.RData")
vnames <- net_no_isolates %v% "vertex.names"

vid_in_kp <- which(vnames %in% kp)
vid_in_btwn <- which(vnames %in% btwn)
vid_in_evcent <- which(vnames %in% evcent)
vid_in_brid <- which(vnames %in% brid)

set.vertex.attribute(net_no_isolates, "network_position", "influencer", vid_in_kp)
set.vertex.attribute(net_no_isolates, "network_position", "influencer", vid_in_btwn)
set.vertex.attribute(net_no_isolates, "network_position", "influencer", vid_in_evcent)
set.vertex.attribute(net_no_isolates, "network_position", "influencer", vid_in_brid)

ggnet2(net_no_isolates, size=1, color="network_position", palette="Set1", mode=coords)

plot of chunk unnamed-chunk-8

bitmap("w2_graphics.tiff", res=300, type="tifflzw")
ggnet2(net_no_isolates, size=1, color="network_position", palette="Set1", mode=coords)
dev.off()
## png 
##   2