gpt4 book ai didi

R - 如何选择或分离循环、不规则数据的下半部分?

转载 作者:行者123 更新时间:2023-12-04 07:45:22 26 4
gpt4 key购买 nike

以下是使用循环伏安法获得的数据(50 分)。我只需要分析其中的一部分:下面最左边到最右边点之间的部分(例如,下图中从绿点到蓝点的数据)。

x <- c(-0.4982, -0.3770, -0.2545, -0.1323, -0.0096, 0.1127, 0.2353, 0.3577, 0.4802, 
0.6024, 0.7251, 0.8470, 0.9696, 0.9109, 0.7887, 0.6662, 0.5441, 0.4213, 0.2990,
0.1763, 0.0541, -0.0685, -0.1906, -0.3133, -0.4356, -0.4395, -0.3172, -0.1946,
-0.0723, 0.0501, 0.1724, 0.2950, 0.4175, 0.5400, 0.6623, 0.7848, 0.9070, 0.9735,
0.8510, 0.7290, 0.6063, 0.4840, 0.3614, 0.2391, 0.1165, -0.0090, -0.1316, -0.2539,
-0.3765)

y <- c(-3.24903226, -1.26193548, -0.51612903, -0.09741935, 0.21161290, 0.45870968,
0.69096774, 1.26387097, 4.03225806, 4.77806452, 4.55677419, 3.88129032,
3.36645161, 2.23677419, 1.37741935, 0.74516129, 0.22645161, -0.23161290,
-0.74129032, -1.66387097, -3.84709677, -6.11225806, -7.21741935, -6.37548387,
-4.11225806, -1.88516129, -0.78967742, -0.24709677, 0.08774194, 0.35096774,
0.57612903, 0.90193548, 2.16322581, 4.85935484, 5.02387097, 4.33870968,
3.66258065, 2.88645161, 1.77870968, 1.06000000, 0.48451613, 0.00193548,
-0.46193548, -1.10967742, -2.53161290, -5.13741935, -6.94903226, -7.14387097,
-5.36580645)
图像显示了完整的数据集(黑线)。点是 xy样本数据。当然,我不能简单地切片 y在最左边的 x 下方,即 y[y < y[which.min(x)]]因为我会丢失几乎一半我想要的数据。
任何的想法?谢谢
enter image description here

最佳答案

取 x 减小的点是否可行?

x2 =  x[x < lag(x) | x > lead(x)]
y2 = y[x < lag(x) | x > lead(x)]
plot(x2, y2)
enter image description here
df <- data.frame(x, y)
df2 <- data.frame(x = x[x < lag(x) | x > lead(x)],
y = y[x < lag(x) | x > lead(x)]) # edit added lead to get right edge
library(ggplot2)
ggplot(df, aes(x, y)) +
geom_point() +
geom_path() +
geom_point(data = df2, color = "red", size = 3)
enter image description here

关于R - 如何选择或分离循环、不规则数据的下半部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67224659/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com