[R] Help with tables

Alejandro Rodríguez rodrigueza at schwabe.com.mx
Fri Nov 30 19:10:26 CET 2007


Hello,  I'm new using R and developing tables.

I have a problem in developing a table.  In a questionaire I made I ask this
question "Please tell me the first three sympthoms caused by Respiratory
tract infection you've caught this year", then the people answer three
sympthoms, the first mention (Top of mind) is saved in a variable called
"P2_A", the second mention in a variable called "P2_B" and the third mention
in "P2_C".  Each answer is coded with numbers like this:

1 = Flu
2 = Cough
3 = Asthma
....

13 = Fever

I've already done a K-cluster analysis and segmented my data base.  So my
first task is to develop tables to develop tables of frequencies crossing
Cluster vs. "P2_A" in order to know which are the top of mind products and
their frequencies by cluster, then the second mention and third mention.
I've used this instruction which worked well:

> table(infec1,aglomera)
      aglomera
infec1   1   2   3   4
    1  117  88  76  83
    2   10  10   9   7
    3   15  11  14  14
    4    2   0   1   1
    5    2   3   1   0
    6    1   0   1   0
    8    3   3   0   1
    9    3   1   1   0
    11   0   0   1   1

Where "infec1" is a factor of "P2_A" and "aglomera" is a factor of the
variable "Cluster" I made.  It worked well when I study them
separately...however I would like to know the TOTAL mentions of each
sympthom by cluster.  I've done this exercise in SPSS using the "Multiple
Response" instruction first grouping my three variables (i.e. "P2_A", "P2_B"
and "P2_C") into a variable called "sick" and cross tabulating it vs. QCL_1
(my cluster variable) and it gave me the table I need in this way (showed at
the bottom of this mail):

How can I made a table like this in R???.  I've tried combining my variables
in a matrix and using xtabs, ftable, table, structable and a lot of
combination of them but I haven't had succed with any of them.

Please help me with this issue, I don't want to keep using SPSS any more.

Thanx in advance.

P.D. Result from SPSS is shown below.



                * * *  C R O S S T A B U L A T I O N  * * *

   $SICK (group)  mr sick
by QCL_1  Cluster Number of Case


                       QCL_1

                Count  I
                       I                                      Row
                       I                                     Total
                       I     1  I     2  I     3  I     4  I
$SICK          --------+--------+--------+--------+--------+
                    1  I   130  I    97  I    83  I    89  I   399
  Gripe, influenza, ca I        I        I        I        I  83.1
                       +--------+--------+--------+--------+
                    2  I    53  I    55  I    42  I    46  I   196
  Tos de cualquier tip I        I        I        I        I  40.8
                       +--------+--------+--------+--------+
                    3  I    33  I    36  I    36  I    39  I   144
  Dolor irritación     I        I        I        I        I  30.0
                       +--------+--------+--------+--------+
                    4  I     5  I     1  I     2  I     3  I    11
  Bronquitis           I        I        I        I        I   2.3
                       +--------+--------+--------+--------+
                    5  I     5  I     4  I     1  I     0  I    10
  Sinusitis            I        I        I        I        I   2.1
                       +--------+--------+--------+--------+
                    6  I     1  I     1  I     1  I     3  I     6
  Rinitis              I        I        I        I        I   1.3
                       +--------+--------+--------+--------+
                    8  I     8  I     6  I     4  I     4  I    22
  Amigdalitis          I        I        I        I        I   4.6
                       +--------+--------+--------+--------+
                    9  I     6  I     4  I     1  I     2  I    13
  Faringitis           I        I        I        I        I   2.7
                       +--------+--------+--------+--------+
                   10  I     1  I     2  I     2  I     3  I     8
  Laringitis           I        I        I        I        I   1.7
                       +--------+--------+--------+--------+
                   11  I     1  I     1  I     1  I     1  I     4
  Neumonia             I        I        I        I        I    .8
                       +--------+--------+--------+--------+
                   13  I     0  I     0  I     1  I     0  I     1
  Asma                 I        I        I        I        I    .2
                       +--------+--------+--------+--------+
               Column      153      116      104      107      480
                Total     31.9     24.2     21.7     22.3    100.0

Percents and totals based on respondents

480 valid cases;  0 missing cases



Act. Calef Alejandro Rodríguez Cuevas
Analista de mercado

Laboratorios Farmasa S.A. de C.V.
Schwabe Mexico, S.A. de C.V.

Bufalo Nr. 27
Col. del Valle 03100
Mexico, D.F.
Mexico

Tel. 52 00 26 80
email: rodrigueza at schwabe.com.mx

www.schwabe.com.mx
www.umckaloabo.com.mx



More information about the R-help mailing list