1

I have a mosaic plot that looks like this

but I need to show the proportions of Countries relative to roles, i.e. flip the chart. Is it possible to do without transposing the table?

thanks.

Eloo
  • 125
  • 11

1 Answers1

0

You can play with the argument split determining the split order of the variables and dir for the split direction (horizontal vs. vertical). For example, both of these split in Roles first and then show the conditional proportions of Countries given Roles (either horizontally or vertically):

tab <- structure(c(12, 14, 23, 12, 26, 13), .Dim = c(3L, 2L),
  .Dimnames = structure(list(
    Countries = c("American", "European", "Japanese"),
    Roles = c("student", "staff")),
  .Names = c("Countries", "Roles")), class = "table")
mosaicplot(tab, sort = 2:1, dir = c("h", "v"))
mosaicplot(tab, sort = 2:1, dir = c("v", "h"))

mosaic

Note that the mosaic() function in package vcd also comes with a formula-based interface and more display options.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49