rpruim/mosaic — Issue #56: Decide on desired behaviors for aggregating statistics functions
Author: rpruim
Created: 2012-03-08 19:05:02+00:00
State: open
Labels: design, feature

I'm wondering what (if anything) we want the following use cases to produce. See below for the current results.

**Output Format(s)**
Currently output is a (named) vector. This provides reasonable looking screen output and makes it easy to throw things into do().

**Conditioning**

What (if anything) do we want conditioning to do?

```R
> mean(cesd~ sex & homeless, HELPrct)
female.homeless male.homeless female.housed male.housed
38.42500 32.98225 35.97015 30.27684
> mean(cesd~ sex | homeless, HELPrct)
female.homeless male.homeless female.housed male.housed homeless
38.42500 32.98225 35.97015 30.27684 34.02392
housed
31.84016
```

**Cross-tabulated counts and proportions?**
We already have mtable(), so this isn't strictly necessary, but we could connect up count() and prop() with mtable() if we wanted. At a minimum we should probably catch these cases and throw a stop message that is prettier than these errors.

```R
> prop( ~ sex, HELPrct )
prop.female
0.2362031
> prop( sex ~ homeless, HELPrct )
Error in .local(x, ..., level = level, na.rm = na.rm) :
Invalid formula type. Perhaps you should try mtable().
> prop( ~ sex & homeless, HELPrct )
prop.
NaN
Warning message:
In Ops.factor(sex, homeless) : & not meaningful for factors
```