我创建了一个实际上是4种不同的ggplots的大型曲线,使用包含4个不同结果的结果的数据框架。

问题描述 投票:0回答:1

对于在不同数据集中替换的特定情况,您可以使用

%+%

运算符。 我会如下:

p0 <- logit_results %>% filter(outcome == "Time_Sport", term != "(Intercept)") %>% ggplot(aes(x = estimate, y = term)) + geom_point(aes(color = treat), size = 2) + facet_wrap(~ treat, nrow = 2, labeller = as_labeller(condition_labels))
p1 <- p0 + labs(title = "Time for sports")
money_data <- logit_results %>% filter(outcome == "Money_Sport", term != "(Intercept)")
p2 <- p0 %+%  money_data +  labs(title = "Money for sports")

p1+p2
r ggplot2
1个回答
0
投票

对于值得的,您也可以使用

aes()
语句覆盖先前指定的映射:

gg0 <- ggplot(aes(mpg, cyl), data = mtcars) + geom_point()
gg0 + (gg0 + aes(y = hp))
(尽管通过重塑数据并将其重塑来实现这个特定示例,然后进行。)

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.