可能重复:
使用 R 计算图中的峰值
我有一个包含两列(ppm 和频率)的表。数据来自核磁共振光谱。我用数据绘制了图表。我从中得到了光谱图像。
我需要从光谱中找到高于 y 轴某个值的峰值。我的数据看起来像这样。它的 ppm 值从 11 到 -1。
我需要找到 y 值至少为 5 的峰值。任何帮助我解决这个问题。从零开始的值属于频率列。
.data <- structure(list(ppm = c(11.3633, 11.3629, 11.3625, 11.3621, 11.3617,
11.3613, 11.361, 11.3606, 11.3602, 11.3598, 11.3594, 11.359,
11.3586, 11.3582, 11.3578, 11.3574, 11.357, 11.3566, 11.3562,
11.3558, 11.3554, 11.355, 11.3546, 11.3542, 11.3538, 11.3534,
11.353, 11.3526, 11.3522, 11.3518, 11.3514, 11.351, 11.3506,
11.3502, 11.3499, 11.3495, 11.3491, 11.3487, 11.3483, 11.3479,
11.3475, 11.3471, 11.3467), freq = c(0.00498359, 0.00511016,
0.00557969, 0.00732578, 0.00936094, 0.00874531, 0.00472031, 0.00185781,
0.00498438, 0.0115414, 0.0142, 0.0108344, 0.00561406, 0.000523438,
-0.00586406, -0.0102078, -0.00525078, 0.0073375, 0.0149227, 0.0105781,
0.00294766, 0.00271172, 0.00764531, 0.00919609, 0.00638828, 0.00396953,
0.00251797, -0.000163281, -0.00205703, 4.53125e-05, 0.00394922,
0.00587578, 0.0070375, 0.00937109, 0.00945234, 0.00447656, -0.000355469,
0.000999219, 0.00497031, 0.00409922, -0.000359375, -0.00106484,
0.00263672)), .Names = c("ppm", "freq"), class = "data.frame", row.names = c(NA,
-43L))