Re: [R] tabulation on dataframe question

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Mon, 18 Feb 2008 12:58:03 -0300

Try this:

with(x,

    {tmp <- table(x[Dist==0.2,c('GrpA', 'GrpB')])

     tmp[lower.tri(tmp)] <- tmp[upper.tri(tmp)]
     tmp})

On 18/02/2008, Karin Lagesen <karin.lagesen_at_medisin.uio.no> wrote:
>
> 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
>
> ______________________________________________
> 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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
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.
Received on Mon 18 Feb 2008 - 16:48:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Feb 2008 - 17:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive