[R] Can 'mosaic' be used with a continuous variable?

Achim Zeileis Achim.Zeileis at uibk.ac.at
Wed Sep 14 19:45:38 CEST 2011

On Wed, 14 Sep 2011, Mauricio Cornejo wrote:

> Hello,
> I'm wondering if the 'mosaic' plot of the vcd package (or any other 
> function for that matter) can be used with a continuous variable that 
> should be represented via various categorical variables.? All the 
> documentation I've read lead me to believe that it only works with 
> counts of categories.
> Alternatively, I've thought of first creating a contingency table where 
> the frequencies would really be the values of my continuous variable as 
> opposed to counts ... but I don't know how to do that.

Well, you can always use cut() to create a categorical variable from a 
continuous variable. But you have to do that in advance before calling 

For a bivariate display with a continuous x and a categorical y, you can 
use spine() which does the categorization for you.


> Any insight would be appreciated.
> Thanks,
> Mauricio
> 	[[alternative HTML version deleted]]

More information about the R-help mailing list