Closed chadbot closed 8 years ago
Sorry for the long delay with my reply, but I was thinking how to address this request. In short, you can already do this by passing dnn
for descr::CrossTable
, eg:
> pander(descr::CrossTable(mtcars$am, mtcars$gear, dnn = c('AM', 'GEAR'), prop.r = FALSE, prop.c = FALSE, prop.chisq = FALSE))
------------------------------------------------
\ GEAR\ \ \ \
AM 3 4 5 Total
--------- -------- --------- --------- ---------
**0**\ \ \ \ \
N\ 15\ 4\ 0\ 19\
Total(%) 46.875% 12.500% 0.000%
**1**\ \ \ \ \
N\ 0\ 8\ 5\ 13\
Total(%) 0.000% 25.000% 15.625%
Total 15 12 5 32
------------------------------------------------
But this can be achieved with a standard table
as well, but calling ftable
on it before passing to pander
:
> pander(ftable(table(mtcars$am, mtcars$gear, mtcars$cyl, dnn = c('AM', 'GEAR', 'CYL'))))
-- ---- ---- -- -- --
CYL 4 6 8
AM GEAR
0 3 1 2 12
4 2 2 0
5 0 0 0
1 3 0 0 0
4 6 2 0
5 2 1 2
-- ---- ---- -- -- --
As we are already using ftable
inside of pander
, it would be trivial to include the option to pass dnn
to it when it comes to a standard table
, so will probably push an update on this in the near future.
Until then, looking forward to any feedback you may have.
Thanks for the reply--and sorry for the delay in my own response! This is an easy workaround. Adding a dnn
parameter for normal tables would still be nice if the implementation is easy, but obviously not a high priority.
Thanks for all your work on this! Really great stuff.
This idea came to my mind again and I was just about to push an update to pandoc.table
to have dnn
argument, but I realized that unfortunately we cannot have global support for that, only for 2+ dimensional tables, on which we call ftable
. Based on this, I think this should remain outside of pander
, so that you can use the dnn
parameter while creating the table (via table
, ftable
or eg CrossTable
) prior to calling pander
.
Please reopen if you have suggestions on a more general solution.
Currently,
pander::pander.table
suppresses table dimension names. It would be very nice to have an option to include these in the output. Better yet would be an option to specify custom dimension names in the output, akin to thednn
parameter indescr::CrossTable
.