Rapporter/pander — pull request #145 by RomanTsegelskyi (2014-12-25 18:06:48+00:00)
Title: New S3 method for CrossTable

I completely rewrote S3 method for CrossTable. I used some ideas from `xtable` package. Now the solution seems more robust (I tasted more example than before). There is one decision we need to make though. I set `split.tables` to Inf [here](https://github.com/Rapporter/pander/blob/873c795c50ac3e1ee98a01a425e4e94f3012dd74/R/S3.R#L878).
It is needed because table has not `rownames`, so if splitting happens there is no `rownames` for next tables. What do you think? Here is an example,
**With split.tables = Inf**
```
> pander(ct1)

---------------------------------------------------------------------
0-39g/day 40-79 80-119 120+ Total
------------ ----------- ----------- ----------- ----------- --------
**25-34**\ \ \ \ \ \
N\ 4\ 4\ 3\ 4\ 15\
Chi-square\ 0.0016\ 0.0016\ 0.0938\ 0.0494\ \
Column(%)\ 17.3913%\ 17.3913%\ 14.2857%\ 19.0476%\ \
Total(%) 4.5455% 4.5455% 3.4091% 4.5455%

**35-44**\ \ \ \ \ \
N\ 4\ 4\ 4\ 3\ 15\
Chi-square\ 0.0016\ 0.0016\ 0.0494\ 0.0938\ \
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 14.2857%\ \
Total(%) 4.5455% 4.5455% 4.5455% 3.4091%

**45-54**\ \ \ \ \ \
N\ 4\ 4\ 4\ 4\ 16\
Chi-square\ 0.0079\ 0.0079\ 0.0087\ 0.0087\ \
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 19.0476%\ \
Total(%) 4.5455% 4.5455% 4.5455% 4.5455%

**55-64**\ \ \ \ \ \
N\ 4\ 4\ 4\ 4\ 16\
Chi-square\ 0.0079\ 0.0079\ 0.0087\ 0.0087\ \
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 19.0476%\ \
Total(%) 4.5455% 4.5455% 4.5455% 4.5455%

**65-74**\ \ \ \ \ \
N\ 4\ 3\ 4\ 4\ 15\
Chi-square\ 0.0016\ 0.2161\ 0.0494\ 0.0494\ \
Column(%)\ 17.3913%\ 13.0435%\ 19.0476%\ 19.0476%\ \
Total(%) 4.5455% 3.4091% 4.5455% 4.5455%

**75+**\ \ \ \ \ \
N\ 3\ 4\ 2\ 2\ 11\
Chi-square\ 0.0054\ 0.4402\ 0.1488\ 0.1488\ \
Column(%)\ 13.0435%\ 17.3913%\ 9.5238%\ 9.5238%\ \
Total(%) 3.4091% 4.5455% 2.2727% 2.2727%

Total\ 23\ 23\ 21\ 21\ 88\
26.1364% 26.1364% 23.8636% 23.8636%
---------------------------------------------------------------------
```
**Without split.tables = Inf**
```
> pander(ct1)

------------------------------------------------------------
0-39g/day 40-79 80-119 120+
------------ ----------- ----------- ----------- -----------
**25-34**\ \ \ \ \
N\ 4\ 4\ 3\ 4\
Chi-square\ 0.0016\ 0.0016\ 0.0938\ 0.0494\
Column(%)\ 17.3913%\ 17.3913%\ 14.2857%\ 19.0476%\
Total(%) 4.5455% 4.5455% 3.4091% 4.5455%

**35-44**\ \ \ \ \
N\ 4\ 4\ 4\ 3\
Chi-square\ 0.0016\ 0.0016\ 0.0494\ 0.0938\
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 14.2857%\
Total(%) 4.5455% 4.5455% 4.5455% 3.4091%

**45-54**\ \ \ \ \
N\ 4\ 4\ 4\ 4\
Chi-square\ 0.0079\ 0.0079\ 0.0087\ 0.0087\
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 19.0476%\
Total(%) 4.5455% 4.5455% 4.5455% 4.5455%

**55-64**\ \ \ \ \
N\ 4\ 4\ 4\ 4\
Chi-square\ 0.0079\ 0.0079\ 0.0087\ 0.0087\
Column(%)\ 17.3913%\ 17.3913%\ 19.0476%\ 19.0476%\
Total(%) 4.5455% 4.5455% 4.5455% 4.5455%

**65-74**\ \ \ \ \
N\ 4\ 3\ 4\ 4\
Chi-square\ 0.0016\ 0.2161\ 0.0494\ 0.0494\
Column(%)\ 17.3913%\ 13.0435%\ 19.0476%\ 19.0476%\
Total(%) 4.5455% 3.4091% 4.5455% 4.5455%

**75+**\ \ \ \ \
N\ 3\ 4\ 2\ 2\
Chi-square\ 0.0054\ 0.4402\ 0.1488\ 0.1488\
Column(%)\ 13.0435%\ 17.3913%\ 9.5238%\ 9.5238%\
Total(%) 3.4091% 4.5455% 2.2727% 2.2727%

Total\ 23\ 23\ 21\ 21\
26.1364% 26.1364% 23.8636% 23.8636%
------------------------------------------------------------

Table: Table continues below

--------
Total
--------
\
15\
\
\

\
15\
\
\

\
16\
\
\

\
16\
\
\

\
15\
\
\

\
11\
\
\

88\
--------
```