[R] Type of multi-valued variable

Fan xiao.gang.fan1 at libertysurf.fr
Sat Feb 15 14:30:06 CET 2003


Thanks to Frank for pointing out that. There're so many "misc" in the 
package hmisc, I haven't yet explored all the functionalities !

The implementation of mChoice / summary() is very interesting, and it could
be a good starting point for adding more functionalities on the class mChoice.

I'm having a little question on the usage of the function summary.formula() in hmisc:
how to get the cross tabluations result like an array, as what xtabs does ?

For example, suppose "titanic" is a dataset as the following:
> str(titanic)
`data.frame':   1313 obs. of  11 variables:
 $ pclass   : Factor w/ 3 levels "1st","2nd","3rd": 1 1 1 1 1 1 1 1 1 1 ...
 $ survived : int  1 0 0 0 1 1 1 0 1 0 ...
 $ sex      : Factor w/ 2 levels "female","male": 1 1 2 1 2 2 1 2 1 2 ...
 $ age      : num  29.000  2.000 30.000 25.000  0.917 ...
 ...

> ftable(xtabs( ~ sex + pclass + survived, data=titanic))
              survived   0   1
sex    pclass                 
female 1st               9 134
       2nd              13  94
       3rd             134  79
male   1st             120  59
       2nd             148  25
       3rd             440  58

My question is how to get that with hmisc::summary() ?
(survived could be a mChoice variable)

Thanks in advance
--
Fan

Frank E Harrell Jr a écrit :
> 
> On Mon, 10 Feb 2003 21:51:50 +0100
> Fan <xiao.gang.fan1 at libertysurf.fr> wrote:
> 
> > Hi,
> >
> > I've read in the past a thead in the R discussion list
> > about the multi-valued type variable (what was called checklist).
> > At the moment Gregory had intention to add some general code
> > in his gregmisc package.
> >
> > I'm wondering if there's some general code / packages available ?
> >
> > A general class for taking account this type of variable
> > would be very useful in the domain of survey processings,
> > as multi-responses questions are often used.
> > The simple operations applied to these variables are holecount,
> > cross tabulations with others variables, transformation to single
> > coded variables like number of responses, etc.
> >
> > Thanks in advance for any help
> > --
> > Fan
> >
> 
> Fan, Take a look at p. 38-44 of http://hesweb1.med.virginia.edu/biostat/s/doc/summary.pdf where examples of the mChoice (multiple choice) function in Hmisc are given.
> 
> --
> Frank E Harrell Jr              Prof. of Biostatistics & Statistics
> Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
> U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat




More information about the R-help mailing list