frequency table?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
set
Reply | Threaded
Open this post in threaded view
|

frequency table?

set
Hello R-users,

I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a table which tells me how many times each individual occurs with another. I don't really know how such a table is called...it is not a frequency table....My eventual goal is to make Venn-diagrams from the occurence of my individuals.

So I've this:

cluster   ind1 ind2 ind3 etc.
1            0      1     2
2            3       0    1
3            1       1     1

And I want to go to this:
            ind1      ind2      ind3
ind1      0          4            2
ind2      4          0            4
ind3      2           4           1

is there a way to do this?
Thank you for your help
Reply | Threaded
Open this post in threaded view
|

Re: frequency table?

Jim Lemon
On 12/04/2011 08:21 PM, set wrote:

> Hello R-users,
>
> I've got a file with individuals as colums and the clusters where they occur
> in as rows. And I wanted a table which tells me how many times each
> individual occurs with another. I don't really know how such a table is
> called...it is not a frequency table....My eventual goal is to make
> Venn-diagrams from the occurence of my individuals.
>
> So I've this:
>
> cluster   ind1 ind2 ind3 etc.
> 1            0      1     2
> 2            3       0    1
> 3            1       1     1
>
> And I want to go to this:
>              ind1      ind2      ind3
> ind1      0          4            2
> ind2      4          0            4
> ind3      2           4           1
>
> is there a way to do this?

Hi set,
Your example is a bit hard to figure out. In particular, individual 1
seems to be in cluster 2 three times, and individual 3 in cluster 1
twice. I could understand it if the top table looked like this:

cluster   ind1 ind2 ind3 ...
1            0    1    1 ...
2            1    0    1 ...
3            1    1    1 ...

That tells me that individual 1 is in cluster 2 and 3 but not in cluster
1, and so on. If you look at the first example in the intersectDiagram
function in the plotrix package, you will see something similar, except
that individuals are rows and common attributes (belonging to sets) are
columns. You can get an intersection diagram from that showing how many
individuals are in each combination of sets. This is similar to a Venn
diagram, except that the population of each intersection is represented
by the width of a rectangle and a text representation of that population.

Thinking about it, maybe you are trying to represent both types of
individuals (that is, there exists more than one of individual type 1
and so on) and attributes (belonging to clusters). In this case you are
trying to get the intersections of two independent groups of sets.

So, I created a dataset in which individuals can have personal
characteristics (sex, age) and scholastic characteristics (which
subjects they study).

funnystuff<-data.frame(math=sample(c(0,1),100,TRUE),
  biology=sample(c(0,1),100,TRUE),
  english=sample(c(0,1),100,TRUE),
  sex=sample(c(0,1),100,TRUE),
  over18=sample(c(0,1),100,TRUE))
library(plotrix)
intersectDiagram(funnystuff,main="Studies by sex and age",sep="\n")

This gives me an interesting diagram from which I can get various
intersections of these two groups of attributes. Is this what you are
seeking?

Jim

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: frequency table?

Brad Schneid
In reply to this post by set
Set,

This is the same post as your "Similarity Matrix" post.

I'm not trying to be a smart ass here, but ... ?Can you fit a square peg in a round hole?... yes, but it doesn't mean it belongs there.  

I suggest you get a piece of paper and a pencil and figure out 1) what you are trying to do and why, and 2) how you would do that by hand.  After you do that, you should be able to figure this out on your own or formulate a question to post that someone will be able to answer.  Reading might help as well.


set wrote
Hello R-users,

I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a table which tells me how many times each individual occurs with another. I don't really know how such a table is called...it is not a frequency table....My eventual goal is to make Venn-diagrams from the occurence of my individuals.

So I've this:

cluster   ind1 ind2 ind3 etc.
1            0      1     2
2            3       0    1
3            1       1     1

And I want to go to this:
            ind1      ind2      ind3
ind1      0          4            2
ind2      4          0            4
ind3      2           4           1

is there a way to do this?
Thank you for your help
Reply | Threaded
Open this post in threaded view
|

Re: frequency table?

Sarah Goslee
After that, you might consult the source code for distance() in ecodist.
That function was specifically written to make it easy for people to
add new dissimilarity/similarity metrics, and I think you'll find it helpful
(even if you just extract the bit you need rather than expand the whole
function).

Sarah

On Mon, Dec 5, 2011 at 9:40 PM, B77S <[hidden email]> wrote:

> Set,
>
> This is the same post as your "Similarity Matrix" post.
>
> I'm not trying to be a smart ass here, but ... ?Can you fit a square peg in
> a round hole?... yes, but it doesn't mean it belongs there.
>
> I suggest you get a piece of paper and a pencil and figure out 1) what you
> are trying to do and why, and 2) how you would do that by hand.  After you
> do that, you should be able to figure this out on your own or formulate a
> question to post that someone will be able to answer.  Reading might help as
> well.
>
>
>
> set wrote
>>
>> Hello R-users,
>>
>> I've got a file with individuals as colums and the clusters where they
>> occur in as rows. And I wanted a table which tells me how many times each
>> individual occurs with another. I don't really know how such a table is
>> called...it is not a frequency table....My eventual goal is to make
>> Venn-diagrams from the occurence of my individuals.
>>
>> So I've this:
>>
>> cluster   ind1 ind2 ind3 etc.
>> 1            0      1     2
>> 2            3       0    1
>> 3            1       1     1
>>
>> And I want to go to this:
>>             ind1      ind2      ind3
>> ind1      0          4            2
>> ind2      4          0            4
>> ind3      2           4           1
>>
>> is there a way to do this?
>> Thank you for your help
>>
--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[hidden email] 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.