[R] Is there a bug in CrossTable (gmodels)

Marc Schwartz (via MN) mschwartz at mn.rr.com
Tue May 2 18:00:11 CEST 2006


On Tue, 2006-05-02 at 17:21 +0200, Albert Sorribas wrote:
> Library gmodels include a function CrossTable that is useful for
> crosstabulation. In the help, it is indicated that one can call this
> function as CrossTable(data), were data is a matrix. However, when I try
> to use this option, it doesn't help. Any idea? Is there a bug?
> 
> Thanks for your help.

Prof. Sorribas,

Can you please provide an example of the error and/or output you are
getting?

I am reviewing the code and think that I may see the problem, but want
to be sure that we are seeing the same thing, which may be an error such
as:

Error in cat(SpaceSep1, "|", ColData, "\n") :
        object "ColData" not found


This would appear to occur when 'x' is a matrix. The code is not picking
up the second dimname for the matrix/table if present or otherwise
setting a default value for 'ColData'. It does get set if one explicitly
sets the 'dnn' argument or in the case of 'x' and 'y' being vectors.

Let me know on the above and if correct, a fix would not be difficult to
provide expediently here.

Thanks and regards,

Marc Schwartz




More information about the R-help mailing list