-1

我是 R 和 ggplot2 的新手。我想为我所做的全因子实验创建一个主效应图。

该图应采用低水平的平均值,并绘制一条线到高水平的平均值。到目前为止,我能够使用 stat_summary() 创建方法,但我无法弄清楚如何在省略中心点的同时连接它们。

现在我只是在使用 geom_smooth(),这并不理想。

p <- ggplot(data, aes(t, g_break)) + 
  geom_point() + 
  stat_summary(fun = mean) + 
  stat_summary(fun = mean, geom = "line")

编辑:

我被要求提供一些数据。

structure(list(RunOrder = c(1, 2, 3, 4, 5, 6), us = c(300, 300, 
300, 160, 160, 160), t = c(200, 200, 100, 100, 200, 200), f = c(160, 
400, 400, 400, 400, 160), Blocks = c(1, 1, 1, 1, 1, 1), g_break = c(0.6, 
1, 0.4, 0, 0.1, 0.6)), row.names = c(NA, -6L), class = c("tbl_df", 
"tbl", "data.frame"))
4

1 回答 1

0

这给出了与 using 相同的情节geom_smooth,但我不确定这是否是“省略我的中心点”的意思。因为它与您已经提供的相同,但只是省略了第一个geom_summary.

ggplot(data, aes(t, g_break)) + 
  geom_point() + 
  stat_summary(fun = mean, geom = "line")
于 2020-06-15T11:20:08.767 回答