Does anyone know how to create a typical table 1 in clinical papers using R? To be more specific, I need to report mean/SD for continuous variables and count/percentages for categorical variables for the whole population and also for each group defined by a categorical variable. I would also like to report the p-value for the differences between groups. I saw people has done this for continuous variables only but not for categorical variables. Any help is greatly appreciated.
Asked
Active
Viewed 2,384 times
3
-
look at `knitr`, `xtable`, `sweave`, `latex`, and lots of other things found in the [reproducible research task view on CRAN](http://cran.r-project.org/web/views/ReproducibleResearch.html) – Chase Sep 21 '12 at 15:37
-
there's also lots of good stuff in Frank Harrell's book (*Regression Modeling Strategies*), `Hmisc` package (e.g. the `?describe` function), and `rms` package. As usual, if you gave us a reproducible example of what you want it would help (e.g. "I want to replicate such-and-such a table [paste snapshot of table from the paper], but using these data [provide the data] instead") -- as always, see http://tinyurl.com/reproducible-000 – Ben Bolker Sep 21 '12 at 15:55
-
Super late, but what I'm developing to make my medical research easy may be what you want. https://github.com/kaz-yos/tableone – kaz_yos Feb 12 '14 at 21:38
-
`install.packages("finalfit")` is great for this. http://finalfit.org/articles/finalfit.html – Ewen Dec 20 '18 at 08:33
1 Answers
2
First part, partially answered by:
require(Hmisc)
latex(describe(DFnew[1:400, c("Sex", "GGT")], descript='Table1: Descriptive Statistics')
You will find a lot more worked examples at Harrell's various webpages dedicated to reproducible research. In particular you should look at page 30 (Table 9) in Harrell's monograph describing the tools he has constructed. It's essentially all you were asking for.

IRTFM
- 258,963
- 21
- 364
- 487