[R] Creating a co-occurence matrix

Greg Blevins gblevins at mn.rr.com
Tue Jul 1 08:08:33 CEST 2003

Hello R experts,

I have a data.frame which has a series of 30 variables that are each coded
if a behavior is engaged in, 0 otherwise.

The data.frame looks like this:

                        var1 var2 ...var30
Respondent 1
Respondent 2

I would like to create a matrix (or at least a half-matrix) as follows:

              var1  var2 ...var30
var 2
var 30

where the number at each intersection is the number of people who engaged in
both behaviors.  I could run a whole bunch of tables and input the data by
hand into a new matrix, but I was wondering if there is a way to do this via
a program/function (I looked at "daisy," but concluded this function would
not handle this).

Any help would be appreciated!

Greg Blevins
The Market Solutions Group

More information about the R-help mailing list