Cross tabulating subgroup means

## Settings for RMarkdown http://yihui.name/knitr/options#chunk_options
opts_chunk$set(comment = "", warning = FALSE, message = FALSE, tidy = FALSE, 
    echo = T, fig.width = 10, fig.height = 8)
options(width = 125, scipen = 5, digits = 5)

setwd("~/statistics/Rmedstats/")

Load dataset Arthritis

library(vcd)
data(Arthritis)
head(Arthritis)
  ID Treatment  Sex Age Improved
1 57   Treated Male  27     Some
2 46   Treated Male  29     None
3 77   Treated Male  30     None
4 17   Treated Male  32   Marked
5 36   Treated Male  46   Marked
6 23   Treated Male  58   Marked

Cross-tabulate and show means

library(Hmisc)
summary(Age ~ Treatment +Sex, data = Arthritis, method = "cross", FUN = mean)

 mean by Treatment, Sex 

+---+
|N  |
|Age|
+---+
+---------+------+------+------+
|Treatment|Female| Male |  ALL |
+---------+------+------+------+
| Placebo |32    |11    |43    |
|         |51.625|53.818|52.186|
+---------+------+------+------+
| Treated |27    |14    |41    |
|         |55.741|52.357|54.585|
+---------+------+------+------+
| ALL     |59    |25    |84    |
|         |53.508|53.000|53.357|
+---------+------+------+------+