[英]Flipping a mosaic plot in R
I have a mosaic plot that looks like 我有一个看起来像马赛克图
but I need to show the proportions of Countries relative to roles, ie flip the chart. 但是我需要显示国家相对于角色的比例,即翻转图表。 Is it possible to do without transposing the table? 是否可以不移置桌子而做?
thanks. 谢谢。
You can play with the argument split
determining the split order of the variables and dir
for the split direction (horizontal vs. vertical). 您可以使用参数split
来确定变量的分割顺序 ,以及分割方向 (水平与垂直)的dir
。 For example, both of these split in Roles
first and then show the conditional proportions of Countries
given Roles
(either horizontally or vertically): 例如,这两个都首先在Roles
划分,然后显示被授予Roles
的Countries
的条件比例(水平或垂直):
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"))
Note that the mosaic()
function in package vcd
also comes with a formula-based interface and more display options. 请注意,软件包vcd
中的mosaic()
函数还带有基于公式的界面和更多显示选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.