I have a data like this:
> table(A,B,C) , , C = FALSE B A FALSE TRUE FALSE 177 42 TRUE 6 8 , , C = TRUE B A FALSE TRUE FALSE 5 31 TRUE 4 10
How can I plot this on a single graph, possibly without imposing any hierarchy?
I would try some kind of 3D heatmap, mosaic plot or a sieve plot (available in the vcd package). Isn't the base
mosaicplot() function working with three-way table? (at least
mosaic3d() in the vcdExtra package should work, see e.g. http://datavis.ca/R/)
Here's an example (including a conditional plot):
A <- sample(c(T,F), 100, replace=T) B <- sample(c(T,F), 100, replace=T) C <- sample(c(T,F), 100, replace=T) tab <- table(A,B,C) library(vcd) sieve(tab, shade=TRUE) cotabplot(tab) library(vcdExtra) mosaic3d(tab, type="expected", box=TRUE)
Actually, the rendering of
mosaic3d() rely on the rgl package, so it is hard to give a pretty picture of the result.
I recently came across a paper by Hadley Wickham and I was reminded of this question (I must spend too much time on the site!)
We propose a new framework for visualising tables of counts, proportions and probabilities. We call our framework product plots, alluding to the computation of area as a product of height and width, and the statistical concept of generating a joint distribution from the product of conditional and marginal distributions. The framework, with extensions, is sufﬁcient to encompass over 20 visualisations previously described in ﬁelds of statistical graphics and infovis, including bar charts, mosaic plots, treemaps, equal area plots and ﬂuctuation diagrams.
I know it is typical to try to give greater explanation, but I don't think I can do any better job than the abstract and posting some pictures! The novel examples they present in the right most images (I believe) meet your requirements without imposing a hierarchy.