[R] create a pairwise coocurrence matrix

Joshua Wiley jwiley.psych at gmail.com
Wed Nov 10 22:39:20 CET 2010


Hi Tax,

Because the list dost not accept HTML messages (per posting guide),
your message was converted to plain text, and your table is difficult
to read.  My suggestion would be to start with:

?table
?xtabs

If you make up a minimal example of the data you have, and email it to
us we can give more detailed and specific help.  Suppose your data is
stored under the name, "dat", you can easily provide us the data using
the R function, dput().  For example:

dput(dat)

will give you a bunch of output you can simply copy and paste into
your next plain text email.

Best regards,

Josh


On Wed, Nov 10, 2010 at 12:01 PM, tax botsis <taxbotsis at gmail.com> wrote:
> Hi all,
> I am trying to construct a pairwise coocurrence matrix for certain terms
> appearing in a number of documents. For example I have the following table
> with binary values showing the presence or absence of a certain term in a
> document:
>
>     term1 term2 term3 term4 term5 doc1 1 1 0 0 1 doc2 1 1 0 1 1 doc3 1 0 0
> 0 1
>
> And I want to have a matrix with the number of the pairwise coocurrencies.
> So, based on the above table the matrix should be:
>
>     term1 term2 term3 term4 term5 term1 0 2 0 1 3 term2 2 0 0 1 2 term3 0 0
> 0 0 0
>
> term4
> 1 1 0 0 1
>
> term5
> 3 2 0 1 1
> Any ideas on how to do that?
>
> Tahnks
> Tax
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list