软件 R 中一张图中三幅图的最大值

Max values for three plots in one graph in software R

我有一个包含三个地块的图表。我用包 ggplot2 制作了它们。

  1. 我想使用 R 编程计算三个图何时达到相同的 X C 值。

  2. 我还想在图表上标记点,例如从 x 轴开始有一条纵向虚线。

我尝试使用 which.max,但它只为首先达到高原的地块之一提供了一个值。我想要所有地块同时达到 37 C 的时间值。

你可以这样做,它会给出第一次它们都等于 37 的索引:

# generate example data
x <- c(3:37, rep(37,3))
y <- c(5:37, rep(37,5))
z <- c(7:37, rep(37,7))

# first instance when all are equal to 37
min(which(x == 37 & y == 37 & z ==37))
#> [1] 35

reprex package (v1.0.0)

于 2021 年 3 月 4 日创建