在另一個值I想之前p => 1,以提取的在數據幀中的第一行在C的值,以及提取的一列的值作爲d的值在數據幀的第一行時爲p => 1。如何在數據幀中基於中的R
然後我想下一個後續行中,以確定Ç和d的值時p再次下降< 1。我正在努力知道如何做到這一點。任何意見,將不勝感激。
> dput(df)
structure(list(p = c(0.00032, 0.0045, 0.01, 0.34, 0.5576, 0.89,
1.00238, 1.2356, 4.76, 18.96, 23.56, 34.005, 26.778, 16.543,
12.3276, 5.674, 3.45, 1.987, 0.976, 0.5629, 0.34564, 0.034, 0.0123,
0.0023), c = c("23/10/2016 15:23:34", "23/10/2016 15:23:44",
"23/10/2016 15:23:54", "23/10/2016 15:24:04", "23/10/2016 15:24:14",
"23/10/2016 15:24:24", "23/10/2016 15:24:34", "23/10/2016 15:24:44",
"23/10/2016 15:24:54", "23/10/2016 15:25:04", "23/10/2016 15:25:14",
"23/10/2016 15:25:24", "23/10/2016 15:25:34", "23/10/2016 15:25:44",
"23/10/2016 15:25:54", "23/10/2016 15:26:04", "23/10/2016 15:26:14",
"23/10/2016 15:26:24", "23/10/2016 15:26:34", "23/10/2016 15:26:44",
"23/10/2016 15:26:54", "23/10/2016 15:27:04", "23/10/2016 15:27:14",
"23/10/2016 15:27:24"), d = c(324.5, 234.5, 109.5, 236.4, 86.5,
67.8, 126.4, 139.8, 139.8, 145.6, 257.6, 309, 19.4, 359.5, 299.5,
234.5, 134.5, 136.7, 135.7, 138.9, 223.1, 256.7, 295.6, 312.8
)), .Names = c("p", "c", "d"), class = "data.frame", row.names = c(NA,
-24L))
> df
p c d
1 0.00032 23/10/2016 15:23:34 324.5
2 0.00450 23/10/2016 15:23:44 234.5
3 0.01000 23/10/2016 15:23:54 109.5
4 0.34000 23/10/2016 15:24:04 236.4
5 0.55760 23/10/2016 15:24:14 86.5
6 0.89000 23/10/2016 15:24:24 67.8
7 1.00238 23/10/2016 15:24:34 126.4
8 1.23560 23/10/2016 15:24:44 139.8
9 4.76000 23/10/2016 15:24:54 139.8
10 18.96000 23/10/2016 15:25:04 145.6
11 23.56000 23/10/2016 15:25:14 257.6
12 34.00500 23/10/2016 15:25:24 309.0
13 26.77800 23/10/2016 15:25:34 19.4
14 16.54300 23/10/2016 15:25:44 359.5
15 12.32760 23/10/2016 15:25:54 299.5
16 5.67400 23/10/2016 15:26:04 234.5
17 3.45000 23/10/2016 15:26:14 134.5
18 1.98700 23/10/2016 15:26:24 136.7
19 0.97600 23/10/2016 15:26:34 135.7
20 0.56290 23/10/2016 15:26:44 138.9
21 0.34564 23/10/2016 15:26:54 223.1
22 0.03400 23/10/2016 15:27:04 256.7
23 0./10/2016 15:27:14 295.6
24 0.00230 23/10/2016 15:27:24 312.8
所需的輸出值:
c_1 d_1 c_2 d_2
23/10/2016 15:24:24 126.4 23/10/2016 15:26:34 135.7
是按列'C'下令數據幀? – yeedle
@yeedle:是的。 – jjulip
在你的數據中,p> = 1之前的第一行是'6 0.89000 23/10/2016 15:24:24 67.8'不是'23/10/2016 15:24:24 126.4'。你可以仔細檢查一下嗎? – Abdou