# Re: [R] Hmisc summary.formula formats for binary and continuous variables

From: Frank Harrell <f.harrell_at_vanderbilt.edu>
Date: Sun, 27 Mar 2011 10:20:02 -0700 (PDT)

If by 35 (10%) you mean that 35 is the numerator, this is not such a good idea. That's because it emphasizes something that is not a scientific quantity. A scientific quantity is something that has a meaning outside the current sample. The numerator is dependent on the denominator.

Regarding the other formatting issue, summary.formula with method='reverse' is not flexible enough to allow that.
Frank

Kwok, Heemun wrote:
>
> Hello,
> I am using Hmisc summary.formula, latex and Sweave to produce tables for
> publication. Is it possible to change the formats for binary and
> continuous variables? I would prefer to show 35 (10%) and 1.5 (1.2-1.8)
> rather than 10% (35) and 1.2 / 1.5 / 1.8. Here is a simple example:
>
> sex &lt;- factor(sample(c(&quot;m&quot;,&quot;f&quot;), 500, rep=TRUE))
> age &lt;- rnorm(500, 50, 5)
> treatment &lt;- factor(sample(c(&quot;Drug&quot;,&quot;Placebo&quot;),
> 500, rep=TRUE))
>
> s1 &lt;- summary(~sex + age)
> s2 &lt;- summary(treatment ~ sex + age, method=&quot;reverse&quot;)
> print(s1); print(s2)
>
> Descriptive Statistics (N=500)
>
> +-------+-----------------+
> | | |
> +-------+-----------------+
> |sex : m| 46% (232) |
> +-------+-----------------+
> |age |47.22/50.31/53.37|
> +-------+-----------------+
>
>
>
> Descriptive Statistics by treatment
>
> +-------+-----------------+-----------------+
> | |Drug |Placebo |
> | |(N=257) |(N=243) |
> +-------+-----------------+-----------------+
> |sex : m| 47% (122) | 45% (110) |
> +-------+-----------------+-----------------+
> |age |47.35/50.00/52.68|46.78/50.92/53.97|
> +-------+-----------------+-----------------+
>
> Thanks,
> Heemun
>
>
> -------------------------------------------------
> Heemun Kwok, M.D.
> Research Fellow
> Harbor-UCLA Department of Emergency Medicine
> 1000 West Carson Street, Box 21
> Torrance, CA 90509-2910
> office 310-222-3501, fax 310-212-6101
>
> ______________________________________________
> R-help_at_r-project.org 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.
>

Frank Harrell
Department of Biostatistics, Vanderbilt University
```--
View this message in context: http://r.789695.n4.nabble.com/Hmisc-summary-formula-formats-for-binary-and-continuous-variables-tp3408967p3409563.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org 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.
```
Received on Sun 27 Mar 2011 - 17:22:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Mar 2011 - 17:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.