我有两组固定效果模型的面网格图。在第一组中,我想抑制控制变量(显示为绿色)。在第二组中,如果模型中有一个控制变量
position_dodgev()
.
到目前为止,我发现了这个代码:
library(ggplot2)
library(ggstance)
ggplot(mf, aes(fill=mn)) +
geom_vline(xintercept=0) +
geom_pointrangeh(aes(y=mn, x=coef, group=cv, color=cv,
xmin=coef - se*1.96, xmax=coef + se*1.96),
position=position_dodgev(.5),
show.legend=FALSE) +
scale_color_manual(values=c("green", "red", "green", "red")) +
facet_grid(gr ~ ., scales="free", space="free")
给了我这个:
然而,在模型1中,解释变量是重复的,并且组2模型中的解释变量并不总是在顶部。
我真的想看看这个情节(photoshopped):
那怎么可能
ggplot()
?
数据
mf <- structure(list(coef = c(3.025, 0.762499999999999, -1.44237073106609,
-0.125042600081792, -0.689108910891089, 2.64264321029771, 2.64264321029771
), se = c(5.26319027539381, 3.34469904756018, 2.02098677878979,
2.02098677878979, 2.02098677878979, 0.763989041657158, 0.763989041657158
), mn = structure(c(1L, 1L, 2L, 2L, 3L, 4L, 4L), .Label = c("Model 2c",
"Model 2b", "Model 2a", "Model 1"), class = "factor"), gr = c(2,
2, 2, 2, 2, 1, 1), cv = structure(c(2L, 1L, 2L, 3L, 2L, 2L, 3L
), .Label = c("gear", "vs", "disp"), class = "factor")), row.names = c("vs",
"gear", "vs1", "disp", "1", "11", "2"), class = "data.frame")