我使用metafor包在R中进行了元回归。
res.quad <- rma(mix.minor.1.1_estimates, sei = mix.minor.1.1_errors, mods = ~ poly(minperc, degree=2, raw=TRUE), data=meta2)
res.quad
然后,我构建了一个气泡图
xs <- seq(0, 1, length=10)
sav <- predict(res.quad, newmods=unname(poly(xs, degree=2, raw=TRUE)))
regplot(res.quad, mod=2, pred=sav, xvals=xs, xlab="Proportion of ethnic minority in class", ylab="Ethnic minority homophily")
但是,我想根据城市变量改变气泡的颜色。我不在元回归中使用它,但它存在于我使用的元2数据框中。有什么办法可以满足我的需要吗?
谢谢)
meta2 <- data.frame(mix.minor.1.1_estimates = c(1, -1, 2, 2.3, 4.2, 0, -3.5),
mix.minor.1.1_errors = c(0.1, 0.5, 0.3, 0.3, 0.2, 0.1, 0.5),
city = c("n", "s", "n", "s", "n", "s", "n"),
minperc = c(0.8, 0.9, 0.1, 0.6, 0.3, 0.2, 0.5))
bg
和 col
参数允许您调整点的(背景)颜色,并接受向量作为参数。请参阅文档。例如:
regplot(res.quad, mod=2, pred=sav, xvals=xs,
xlab="Proportion of ethnic minority in class",
ylab="Ethnic minority homophily",
bg=ifelse(meta2$city == "n", "firebrick", "dodgerblue"))