我有一些来自实验的数据,其中有7个变量有两个级别来生成实验条件。因此,存在128(2 ^ 7)个不同的变量组合。我已经看到格子样式面板图中呈现的一些数据看起来不错,但我只是遇到了针对2个不同变量执行此操作的数据。但是,我想知道是否有人提出有超过2个变量的数据的想法(即列联表不起作用!)
我提供了一些示例数据来解释如果不清楚我的数据是什么样的:
cond1 <- c(1,2)
cond2 <- c(1,2)
cond3 <- c(1,2)
cond4 <- c(1,2)
cond5 <- c(1,2)
cond6 <- c(1,2)
cond7 <- c(1,2)
conditions <- expand.grid(cond1,cond2,cond3,cond4,cond5,cond6,cond7)
conditions <- sapply(conditions, rep.int, times=10)
data <- runif (nrow(conditions))
df1 <- cbind(conditions, data)
答案 0 :(得分:1)
我可以开箱即用6,如果你为Var7
中的每个级别绘制相同的情节,你就有7个尺寸。他们可能会使用一些调整。
df1 <- data.frame(df1)
library(ggplot2)
xy1 <- ggplot(droplevels(df1[df1$Var7 == 1,]), aes(x = as.factor(Var1),
y = as.factor(Var2),
color = as.factor(Var3),
shape = as.factor(Var4),
alpha = Var5,
size = data)) +
geom_jitter() +
facet_wrap(~ as.factor(Var6))
xy2 <- ggplot(droplevels(df1[df1$Var7 == 2,]), aes(x = as.factor(Var1),
y = as.factor(Var2),
color = as.factor(Var3),
shape = as.factor(Var4),
alpha = Var5,
size = data)) +
geom_jitter() +
facet_wrap(~ as.factor(Var6))
library(gridExtra)
grid.arrange(xy1, xy2, ncol = 1)
答案 1 :(得分:1)