[R] tabulation on dataframe question

Karin Lagesen karin.lagesen at medisin.uio.no
Mon Feb 18 16:16:40 CET 2008


I have a data frame with data similar to this:

NameA  GrpA   NameB GrpB Dist
A      Alpha  B     Alpha       0.2
A      Alpha  C     Beta        0.2
A      Alpha  D     Beta        0.4
B      Alpha  C     Beta        0.2
B      Alpha  D     Beta        0.1
C      Beta   D     Beta        0.3

Dist is a distance measure between two entities. The table displays
all to all distances, but the distance between two entities only
appears once. What I would like to get is a table where I get a count
of entities per group where the distance satisfies a certain condition
( equal to zero for instance).

In this case, if the requirement was Distances == 0.2

        Alpha    Beta
Alpha   1        2
Beta    2        0

This resulting table would be symmetrical.

I hope I am able to convey what I would like, and TIA for your help!

Karin
-- 
Karin Lagesen, PhD student
karin.lagesen at medisin.uio.no
http://folk.uio.no/karinlag



More information about the R-help mailing list