答案 0 :(得分:4)
您只是在寻找内置于vcd ::: cotabplot
的面板功能library(vcd)
data("alzheimer", package = "coin")
alz <- xtabs(~smoking + disease + gender, data = alzheimer)
cotabplot(~ smoking + disease | gender, data = alz, panel = cotab_coindep, n = 5000)
答案 1 :(得分:2)
以下是潜在数据的模拟:
Smoker <- sample(c("yes", "no"), 100, T)
Days <- sample(c("thu", "fri", "sat", "sun"), 100, T)
Time <- sample(c("day", "night"), 100, T)
Sex <- sample(c("m", "f"), 100, T)
Value <- sample(1:10, 100, T)
DF <- data.frame(Value, Smoker, Days, Time, Sex)
使用包vcd
生成图:
library(vcd)
cotabplot(~ Smoker + Days + Time | Sex, data = DF, panel = cotab_mosaic, direction = "v")
编辑:上传剧情: