[R] Cross Tables with odfTable in odfweave

Max Kuhn mxkuhn at gmail.com
Mon Mar 2 22:11:05 CET 2009


PJ,

> Hi, I've been trying to prepare some crosstables for some survey questions
> for a client. I have been using the CrossTable function in the gmodels
> package. However, this command only seems to be able to create CrossTables
> in text documents.
>
> I've been trying to use odfTable in odfweave to create tables that are
> standalone objects in the document that I can then convert to other formats,
> copy and paste and do whatever with.

You will have to do some work to get CrossTable results into odfWeave
for a few reasons. The main one is: CrossTable prints the output (as
opposed to outputting an object of a certain class that uses print to
make the results like table() and print.table()). In some cases, it is
easy to translate the output you see on the screen to odf markup. I'm
not sure that this function is one of those cases. That is not a
slight against the function, it just isn't meant to do that.

> The problem is no matter how I try to get the CrossTable into the odfTable,
> i either get an error message saying there is no appropriate method for
> odfTable or the table is inproperly formatted.

It would be nice to have a reproducible example along with the results
of sessionInfo(). Looking at ?odfTable, it has that the main argument
should be "a vector, matrix or data frame". I can' tell if there is a
bug in odfTable or if you are just using it incorrectly.

> Honestly, I'm not even married to using odfTable. All I'm looking for is a
> nicely formatted table, that is a standalone object, that I can copy and
> paste and convert at will, and that contains the column percentages in the
> table.

CrossTable may not be what you want then. The results are a list of
components of the table.

-- 

Max




More information about the R-help mailing list