BenjaminLind

EIES_data.R

Jul 21st, 2014
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 3.06 KB | None | 0 0
  1. # For description, see: https://www.stats.ox.ac.uk/~snijders/siena/EIES_data.htm
  2.     # The Electronic Information Exchange System (EIES) data were collected by Freeman and Freeman (1980). This data set is discussed also in Wasserman and Faust (1994:62-63). This is a network of 32 researchers who participated in an early study on the effects of electronic information exchange, a precursor of email communication.
  3.  
  4. # References:
  5. # Freeman, L.C., and Freeman, S.C., A semi-visible college: Structural effects on a social networks group. Pp. 77-85 in Henderson, M.M., and McNaughton, M.J. (eds.) _Electronic Communication: Technology and Impacts Boulder_, CO: Westview Press, 1980.
  6. # Wasserman, Stanley, and Katherine Faust. _Social Network Analysis: Methods and Applications._ New York and Cambridge: Cambridge University Press, 1994.
  7.  
  8. # To load this dataset, enter the following into R:
  9. #    source("http://pastebin.com/raw.php?i=thqLfnY4")
  10.  
  11. library(igraph)
  12. library(utils)
  13.  
  14. firstdir <- getwd()
  15. newdir <- paste(firstdir, "EIES_data", sep = "/")
  16. download.file("https://www.stats.ox.ac.uk/~snijders/siena/EIES_data.zip", "EIES_data.zip", method = "wget")
  17. unzip("EIES_data.zip", exdir = newdir)
  18. setwd(newdir)
  19.  
  20. eiesatts <- read.table("eies.dat", as.is = TRUE, stringsAsFactors = FALSE, strip.white = TRUE, skip = 3, quote = "", nrows = 32)
  21. colnames(eiesatts) <- c("Researcher", "Original_Code", "Citations", "Discipline")
  22. eiesatts$Discipline_Name <- c("Sociology", "Anthropology", "Statistics", "Psychology")[eiesatts$Discipline]
  23. eiesatts$Discipline_Name[3] <- "Communication"
  24. eiesatts$Discipline_Name[27] <- "Mathematics"
  25.  
  26. friend1 <- read.table("EIES.1", sep = " ", as.is = TRUE, strip.white = TRUE)
  27. friend2 <- read.table("EIES.2", sep = " ", as.is = TRUE, strip.white = TRUE)
  28. eiesmessages <- read.table("messages.asc", nrows = 32, strip.white = TRUE)
  29. eies <- list(t1 = friend1, t2 = friend2, messages = eiesmessages)
  30. rm(friend1, friend2, eiesmessages)
  31. eies <- lapply(eies, as.matrix)
  32. eies$t1 <- graph.adjacency(eies$t1, mode = "directed", weighted = TRUE, diag = FALSE)
  33.  
  34. # The acquaintance description at Snijders's page is incorrect, as it omits tie strength of 0 and "close friend"
  35. # A code of 0 indicates "do not know" (I can't imagine what would be less) and 4 indicates "close friend."
  36. E(eies$t1)$etype <- c("Do not know", "Heard of", "Met", "Friend", "Close Friend")[E(eies$t1)$weight + 1]
  37. eies$t2 <- graph.adjacency(eies$t2, mode = "directed", weighted = TRUE, diag = FALSE)
  38. E(eies$t2)$etype <- c("Do not know", "Heard of", "Met", "Friend", "Close Friend")[E(eies$t2)$weight + 1]
  39.  
  40. eies$messages <- graph.adjacency(eies$messages, mode = "directed", weighted = TRUE, diag = TRUE)
  41.  
  42. eiesvatts <- function(g, atts = eiesatts){
  43.     V(g)$name <- as.character(1:vcount(g))
  44.     for (i in 1:ncol(atts))
  45.         g <- set.vertex.attribute(g, name = colnames(atts)[i], value = atts[, i])
  46.     return(g)
  47.     }
  48. eies <- lapply(eies, eiesvatts)
  49. rm(eiesvatts, eiesatts)
  50.  
  51. sapply(list.files(), file.remove)
  52. setwd(firstdir)
  53. file.remove(newdir)
  54. file.remove("EIES_data.zip")
  55. rm(firstdir, newdir)
Advertisement
Add Comment
Please, Sign In to add comment