I am trying to construct a two-way table where, instead of printing the
two-way frequencies in the table, I would like to print the values of a
third variable that correspond to the frequencies.

 

For example, the following is easily constructed in R

 

> fact1 <- factor(sample(LETTERS[1:3],10,replace=TRUE))

> fact2 <- factor(sample(LETTERS[25:26],10,replace=TRUE))

> fact3 <- letters[1:10]

> data.frame(fact1,fact2,fact3)

   fact1 fact2 fact3

1      C     Z     a

2      A     Y     b

3      A     Y     c

4      C     Z     d

5      A     Z     e

6      A     Y     f

7      B     Y     g

8      B     Y     h

9      C     Z     i

10     A     Y     j

> table(fact1,fact2)

     fact2

fact1 Y Z

    A 4 1

    B 2 0

    C 0 3

 

But I would like to create something like this (done physically by hand)
...

 

     fact2

fact1    Y       Z

    A b,c,f,j    e

    B   g,h      -

    C    -     a,d,i

 

Any help would be appreciated.  Thank you in advance.

 

For what it is worth,

 

> Sys.info()

                     sysname 

                   "Windows" 

                     release 

                        "XP" 

                     version 

"build 2600, Service Pack 2"


	[[alternative HTML version deleted]]


