~mvngu/igraph/doc

« back to all changes in this revision

Viewing changes to nexus/download/kapmine.R

  • Committer: Gabor Csardi
  • Date: 2012-02-21 04:05:12 UTC
  • mfrom: (2640.1.1 0.6-main)
  • Revision ID: csardi.gabor@gmail.com-20120221040512-n2orudv0a2cdw3g1
Merged Nexus branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
url <- "http://vlado.fmf.uni-lj.si/pub/networks/data/ucinet/kapmine.dat"
 
3
tmp <- tempdir()
 
4
dest <- paste(sep="", tmp, "/", "kapmine.dat")
 
5
download.file(url, dest)
 
6
l <- readLines(paste(sep="", tmp, "/kapmine.dat"))
 
7
 
 
8
data <- l[ (grep("^DATA:", l)+1):length(l) ]
 
9
adata <- l[ (grep("^ROW LABELS:", l)+1):(grep("^COLUMN LABELS:", l)-1) ]
 
10
 
 
11
tc <- textConnection(data)
 
12
mat <- scan(tc)
 
13
close(tc)
 
14
 
 
15
mat1 <- mat[1:(length(mat)/2)]
 
16
mat2 <- mat[(length(mat)/2+1):length(mat)]
 
17
 
 
18
mat1 <- matrix(mat1, sqrt(length(mat1)), byrow=TRUE)
 
19
mat2 <- matrix(mat2, sqrt(length(mat2)), byrow=TRUE)
 
20
colnames(mat1) <- rownames(mat1) <- colnames(mat2) <- rownames(mat2) <- adata
 
21
 
 
22
library(igraph)
 
23
g1 <- graph.adjacency(mat1, mode="undirected")
 
24
g2 <- graph.adjacency(mat2, mode="undirected")
 
25
 
 
26
g1$name <- "Kapferer mine, KAPFMM"
 
27
g2$name <- "Kapferer mine, KAPFMU"
 
28
g1$Author <- g2$Author <- "Bruce Kapferer"
 
29
g1$Citation <- g2$Citation <- "Kapferer B. (1969). Norms and the manipulation of relationships in a work context. In J Mitchell (ed), Social networks in urban situations. Manchester: Manchester University Press.\n\nDoreian P. (1974). On the connectivity of social networks. Journal of Mathematical Sociology, 3, 245-258."
 
30
g1$URL <- g2$URL <- "http://vlado.fmf.uni-lj.si/pub/networks/data/ucinet/ucidata.htm"
 
31
 
 
32
kapmine <- list(KAPFMM=g1, KAPFMU=g2)
 
33
save(kapmine, file="/tmp/kapmine.Rdata.gz")