Erich Studerus, Psychiatrische Uni-Klinik
2008-Oct-08 22:49 UTC
[R] NA's in multiple choice summary table in Hmisc
Hi, I have a set of 30 binary variables measuring side effects after drug treatment. Since each subject can have multiple side effects, I want to display these side effects in a multiple choice table. I'm using the summary and mChoice functions of the Hmisc package, because it produces nicely formatted latex tables. My problem is, that table includes a category for people who have at least one absent symptom and I don't know how to exclude it. Here's a very easy reproducible example: library(Hmisc) Symptom1<-c("Headache","Headache",NA) Symptom2<-c(NA,"Anxiety",NA) Symptoms<-mChoice(Symptom1,Symptom2) summary(~Symptoms,method="reverse") Descriptive Statistics (N=3) +-------------------+-------+ | | | +-------------------+-------+ |Symptom1 : Headache|67% (2)| +-------------------+-------+ | NA |67% (2)| +-------------------+-------+ | Anxiety |33% (1)| +-------------------+-------+ Now, I want to either completely exclude the NA category or - if included - it should count the number of people who have NA's in all symptoms rather than in a single symptom. In the example above, the NA's should be 1 instead of 2 cases. I tried to specify na.include=FALSE but it does not work. Any help is highly appreciated. Erich
Frank E Harrell Jr
2008-Oct-09 02:17 UTC
[R] NA's in multiple choice summary table in Hmisc
Erich Studerus, Psychiatrische Uni-Klinik wrote:> Hi, > > I have a set of 30 binary variables measuring side effects after drug > treatment. Since each subject can have multiple side effects, I want to > display these side effects in a multiple choice table. I'm using the > summary and mChoice functions of the Hmisc package, because it produces > nicely formatted latex tables. My problem is, that table includes a > category for people who have at least one absent symptom and I don't > know how to exclude it. > > Here's a very easy reproducible example: > > library(Hmisc) > Symptom1<-c("Headache","Headache",NA) > Symptom2<-c(NA,"Anxiety",NA) > Symptoms<-mChoice(Symptom1,Symptom2) > summary(~Symptoms,method="reverse") > Descriptive Statistics (N=3) > > +-------------------+-------+ > | | | > +-------------------+-------+ > |Symptom1 : Headache|67% (2)| > +-------------------+-------+ > | NA |67% (2)| > +-------------------+-------+ > | Anxiety |33% (1)| > +-------------------+-------+ > > Now, I want to either completely exclude the NA category or - if > included - it should count the number of people who have NA's in all > symptoms rather than in a single symptom. In the example above, the NA's > should be 1 instead of 2 cases. > I tried to specify na.include=FALSE but it does not work. > > Any help is highly appreciated. > > ErichInstead of NA put '' or "" and it should work. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University