MLE_s_BwS
MLE_s_WF
DG == 1
DG == 10
my_plot_DG1 <- ggplot(
estimations_pivoted[estimations_pivoted$DG == 1,],
aes(x = MLE_s_WF, y = MLE_s_BwS)
) +
geom_point(aes(col = as.factor(S)), alpha = 0.5) +
scale_color_manual(values = c("purple2", "yellow")) +
geom_abline(linetype = "dotted") +
xlim(x_lim) + ylim(y_lim) +
theme_minimal()
MLE_s[BwS/WF]
S == 0
(两个不同的地块)时。
S == 0.1
我正在尝试绘制两条水平和两条垂直线:在每种情况下,一条线的平均线,当geom_hline(yintercept = mean(estimations_pivoted[estimations_pivoted$DG == 1 & estimations_pivoted$S == 0,]$MLE_s_BwS), col = "purple2")
geom_hline(yintercept = mean(estimations_pivoted[estimations_pivoted$DG == 1 & estimations_pivoted$S == 0.1,]$MLE_s_BwS), col = "yellow")
当
ggplot
时,另一个线,另一个线。我找不到AES的解决方案。我唯一能想到的就是做
mean
但看起来不贵。这样做有更简单/更优雅的方式吗?
与通常最好先操纵和总结数据。创建了每个组的数据框架。
df <- tibble::tribble(
~N, ~S, ~DG, ~P, ~locus, ~replicate, ~MLE_s_BwS, ~MLE_s_WF,
100L, 0, 1L, 1L, 0L, 0L, -0.174, -0.183,
100L, 0, 1L, 1L, 1L, 0L, 0.143, 0.143,
100L, 0, 1L, 1L, 2L, 0L, -0.0758, -0.0758,
100L, 0.1, 10L, 1L, 3L, 0L, -0.141, -0.141,
100L, 0.1, 10L, 1L, 4L, 0L, 0.102, 0.102,
100L, 0.1, 10L, 1L, 5L, 0L, 0.102, 0.102,
100L, 0.1, 10L, 1L, 5L, 0L, 0.102, 0.102
)
library(tidyverse)
mean_lines <- df |>
summarize(mean_s_BwS = mean(MLE_s_BwS),
mean_s_WF = mean(MLE_s_WF),
.by = S)
mean_lines
#> # A tibble: 2 × 3
#> S mean_s_BwS mean_s_WF
#> <dbl> <dbl> <dbl>
#> 1 0 -0.0356 -0.0386
#> 2 0.1 0.0412 0.0412
facet
函数,以免为每个值编写单独的代码。
DG