-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of William Dunlap
Sent: Tuesday, February 05, 2013 10:47 AM
To: Sebastian Haunss; r-help at r-project.org
Subject: Re: [R] adjacency list to non-symmetric matrix
Try table():
> adj <- table(d) # 'd' is your data.frame
> adj
group
person a b c d
Greg 1 0 0 0
Mary 0 1 0 1
Sam 1 1 1 0
Tom 0 1 1 1
If you have duplicate rows in the d then it will
tally them up. You can can convert positives to
1's with adj[adj>0] <- 1.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
Of Sebastian Haunss
Sent: Tuesday, February 05, 2013 1:07 AM
To: r-help at r-project.org
Subject: [R] adjacency list to non-symmetric matrix
Dear R community,
is there an easy way to convert an adjacency list (or a data-frame)
matrix?
The adjacency list has the following form:
person group
1 Sam a
2 Sam b
3 Sam c
4 Greg a
5 Tom b
6 Tom c
7 Tom d
8 Mary b
9 Mary d
I need the data in a matrix with persons as rows and groups as
a b c d
Sam 1 1 1 0
Greg 1 0 0 0
Tom 0 1 1 1
Mary 0 1 0 1
I know that there are several possibilities in some of the network
adjacency lists to symmetric or sparse matrices, but I couldn't find
into affiliation matrices.
kind regards
Sebastian
--
PD Dr. Sebastian Haunss
SfB 597 - Transformations of the State
Universit?t Bremen
Linzer Str. 9a
28359 Bremen
T: +49-(0)421-218-56654
http://shaunss.ipgovernance.eu/
Recently published:
Haunss, Sebastian (2012), ?Gewalt und Gewaltlosigkeit in sozialen
Forschungsjournal Soziale Bewegungen 25(4): 6?16.
Leifeld, Philip, and Sebastian Haunss (2012), ?Political Discourse
Conflict over Software Patents in Europe?, European Journal of
Political Research 51(3):