Generate LaTeX tables of descriptive statistics


Using a LOT of time on fiddling together tables of descriptive statistics manually in R did not inspire me to look in the CRAN repositories for a R function doing exactly this… yes a bit stubborn… want to find out myself…

So what I had to do was:

  1. handcode the descriptives for each variable, something like prop.table(xtabs( ~ Variable + Group1 + Group2), c(2,3)),
  2. calculate some statistics for each variable (chi^2, one-way-ANOVA, Fisher-exact..) and attach it to the descriptives,
  3. run the code,
  4. copy the plain text output from R back into the editor and finally
  5. add LaTeX or CSV syntax to get the desired results.

Anyway this is over now. A solution exists, of course (thx Kjetil… again):

The package ‘reporttools’ of Kaspar Rufibach.
install.packages("reporttools", dependecies=TRUE)

The most important functions are well:

tableContinuous( vars = c(bmi, ejectionfraction, systolicBP, diastolicBP) , group = sex , subset = significantstenosis , print.pval = "anova")

and

tableNominal() for nominal variables.

The output is LaTeX and it is possible to specify table captions and lables to the tables in the function call. I will give it a try inside Sweave… but first I have to get it to my Linux machine … which is blocked by the corporate firewall … after a recent Mircrosoft powergrab … after a Virusattack (Conficker) … after running XP unpached.

But thats another story

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s