Selecting rows matching a time pattern in R - r

I've been working on this dataset for a while now so I hope I can get some help. I would like to simplify my question to:
How can I select rows having the following time-stamped pattern in column Time: **/**/**** **:**:00?
Hope I was clear! I can attach a head() sample below:
> head(dataraw)
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z Vigilance Head-up Grazing Browsing Moving
1: 17/06/2018 09:36:00 34.333333 19.666667 40.000000 0 150 0 35 27
2: 17/06/2018 09:37:20 9.666667 7.000000 12.333333 0 185 0 0 26
3: 17/06/2018 09:38:40 7.333333 4.000000 8.666667 0 168 0 0 11
4: 17/06/2018 09:40:00 14.000000 9.333333 17.333333 0 99 58 0 11
5: 17/06/2018 09:41:20 19.000000 13.000000 23.333333 0 37 124 0 11
6: 17/06/2018 09:42:40 23.000000 14.000000 27.000000 0 8 196 0 0
Grooming Resting Fleeing Unknown End
1: 17 0 0 11 0
2: 23 0 0 6 0
3: 30 0 0 31 0
4: 35 0 0 37 0
5: 31 0 0 37 0
6: 17 0 0 19 0
Find attached a sample below:
> dput(dataraw[(1:280),])
structure(list(Time = c("17/06/2018 09:36:00", "17/06/2018 09:37:20",
"17/06/2018 09:38:40", "17/06/2018 09:40:00", "17/06/2018 09:41:20",
"17/06/2018 09:42:40", "17/06/2018 09:44:00", "17/06/2018 09:45:20",
"17/06/2018 09:46:40", "17/06/2018 09:48:00", "17/06/2018 09:49:20",
"17/06/2018 09:50:40", "17/06/2018 09:52:00", "17/06/2018 09:53:20",
"17/06/2018 09:54:40", "17/06/2018 09:56:00", "17/06/2018 09:57:20",
"17/06/2018 09:58:40", "17/06/2018 10:00:00", "17/06/2018 10:01:20",
"17/06/2018 10:02:40", "17/06/2018 10:04:00", "17/06/2018 10:05:20",
"17/06/2018 10:06:40", "17/06/2018 10:08:00", "17/06/2018 10:09:20",
"17/06/2018 10:10:40", "17/06/2018 10:12:00", "17/06/2018 10:13:20",
"17/06/2018 10:14:40", "17/06/2018 10:16:00", "17/06/2018 10:17:20",
"17/06/2018 10:18:40", "17/06/2018 10:20:00", "17/06/2018 10:21:20",
"17/06/2018 10:22:40", "17/06/2018 10:24:00", "17/06/2018 10:25:20",
"17/06/2018 10:26:40", "17/06/2018 10:28:00", "17/06/2018 10:29:20",
"17/06/2018 10:30:40", "17/06/2018 10:32:00", "17/06/2018 10:33:20",
"17/06/2018 10:34:40", "17/06/2018 10:36:00", "17/06/2018 10:37:20",
"17/06/2018 10:38:40", "17/06/2018 10:40:00", "17/06/2018 10:41:20",
"17/06/2018 10:42:40", "17/06/2018 10:44:00", "17/06/2018 10:45:20",
"17/06/2018 10:46:40", "17/06/2018 10:48:00", "17/06/2018 10:49:20",
"17/06/2018 10:50:40", "17/06/2018 10:52:00", "17/06/2018 10:53:20",
"17/06/2018 10:54:40", "17/06/2018 10:56:00", "17/06/2018 10:57:20",
"17/06/2018 10:58:40", "17/06/2018 11:00:00", "17/06/2018 11:01:20",
"17/06/2018 11:02:40", "17/06/2018 11:04:00", "17/06/2018 11:05:20",
"17/06/2018 11:06:40", "17/06/2018 11:08:00", "17/06/2018 11:09:20",
"17/06/2018 11:10:40", "17/06/2018 11:12:00", "17/06/2018 11:13:20",
"17/06/2018 11:14:40", "17/06/2018 11:16:00", "17/06/2018 11:17:20",
"17/06/2018 11:18:40", "17/06/2018 11:20:00", "17/06/2018 11:21:20",
"17/06/2018 11:22:40", "17/06/2018 11:24:00", "17/06/2018 11:25:20",
"17/06/2018 11:26:40", "17/06/2018 11:28:00", "17/06/2018 11:29:20",
"17/06/2018 11:30:40", "17/06/2018 11:32:00", "17/06/2018 11:33:20",
"17/06/2018 11:34:40", "17/06/2018 11:36:00", "17/06/2018 11:37:20",
"17/06/2018 11:38:40", "17/06/2018 11:40:00", "17/06/2018 11:41:20",
"17/06/2018 11:42:40", "17/06/2018 11:44:00", "17/06/2018 11:45:20",
"17/06/2018 11:46:40", "17/06/2018 11:48:00", "17/06/2018 11:49:20",
"17/06/2018 11:50:40", "17/06/2018 11:52:00", "17/06/2018 11:53:20",
"17/06/2018 11:54:40", "17/06/2018 11:56:00", "17/06/2018 11:57:20",
"17/06/2018 11:58:40", "17/06/2018 12:00:00", "17/06/2018 12:01:20",
"17/06/2018 12:02:40", "17/06/2018 12:04:00", "17/06/2018 12:05:20",
"17/06/2018 12:06:40", "17/06/2018 12:08:00", "17/06/2018 12:09:20",
"17/06/2018 12:10:40", "17/06/2018 12:12:00", "17/06/2018 12:13:20",
"17/06/2018 12:14:40", "17/06/2018 12:16:00", "17/06/2018 12:17:20",
"17/06/2018 12:18:40", "17/06/2018 12:20:00", "17/06/2018 12:21:20",
"17/06/2018 12:22:40", "17/06/2018 12:24:00", "17/06/2018 12:25:20",
"17/06/2018 12:26:40", "17/06/2018 12:28:00", "17/06/2018 12:29:20",
"17/06/2018 12:30:40", "17/06/2018 12:32:00", "17/06/2018 12:33:20",
"17/06/2018 12:34:40", "17/06/2018 12:36:00", "17/06/2018 12:37:20",
"17/06/2018 12:38:40", "17/06/2018 12:40:00", "17/06/2018 12:41:20",
"17/06/2018 12:42:40", "17/06/2018 12:44:00", "17/06/2018 12:45:20",
"17/06/2018 12:46:40", "17/06/2018 12:48:00", "17/06/2018 12:49:20",
"17/06/2018 12:50:40", "17/06/2018 12:52:00", "17/06/2018 12:53:20",
"17/06/2018 12:54:40", "17/06/2018 12:56:00", "17/06/2018 12:57:20",
"17/06/2018 12:58:40", "17/06/2018 13:00:00", "17/06/2018 13:01:20",
"17/06/2018 13:02:40", "17/06/2018 13:04:00", "17/06/2018 13:05:20",
"17/06/2018 13:06:40", "17/06/2018 13:08:00", "17/06/2018 13:09:20",
"17/06/2018 13:10:40", "17/06/2018 13:12:00", "17/06/2018 13:13:20",
"17/06/2018 13:14:40", "17/06/2018 13:16:00", "17/06/2018 13:17:20",
"17/06/2018 13:18:40", "17/06/2018 13:20:00", "17/06/2018 13:21:20",
"17/06/2018 13:22:40", "17/06/2018 13:24:00", "17/06/2018 13:25:20",
"17/06/2018 13:26:40", "17/06/2018 13:28:00", "17/06/2018 13:29:20",
"17/06/2018 13:30:40", "17/06/2018 13:32:00", "17/06/2018 13:33:20",
"17/06/2018 13:34:40", "17/06/2018 13:36:00", "17/06/2018 13:37:20",
"17/06/2018 13:38:40", "17/06/2018 13:40:00", "17/06/2018 13:41:20",
"17/06/2018 13:42:40", "17/06/2018 13:44:00", "17/06/2018 13:45:20",
"17/06/2018 13:46:40", "17/06/2018 13:48:00", "17/06/2018 13:49:20",
"17/06/2018 13:50:40", "17/06/2018 13:52:00", "17/06/2018 13:53:20",
"17/06/2018 13:54:40", "17/06/2018 13:56:00", "17/06/2018 13:57:20",
"17/06/2018 13:58:40", "17/06/2018 14:00:00", "17/06/2018 14:01:20",
"17/06/2018 14:02:40", "17/06/2018 14:04:00", "17/06/2018 14:05:20",
"17/06/2018 14:06:40", "17/06/2018 14:08:00", "17/06/2018 14:09:20",
"17/06/2018 14:10:40", "17/06/2018 14:12:00", "17/06/2018 14:13:20",
"17/06/2018 14:14:40", "17/06/2018 14:16:00", "17/06/2018 14:17:20",
"17/06/2018 14:18:40", "17/06/2018 14:20:00", "17/06/2018 14:21:20",
"17/06/2018 14:22:40", "17/06/2018 14:24:00", "17/06/2018 14:25:20",
"17/06/2018 14:26:40", "17/06/2018 14:28:00", "17/06/2018 14:29:20",
"17/06/2018 14:30:40", "17/06/2018 14:32:00", "17/06/2018 14:33:20",
"17/06/2018 14:34:40", "17/06/2018 14:36:00", "17/06/2018 14:37:20",
"17/06/2018 14:38:40", "17/06/2018 14:40:00", "17/06/2018 14:41:20",
"17/06/2018 14:42:40", "17/06/2018 14:44:00", "17/06/2018 14:45:20",
"17/06/2018 14:46:40", "17/06/2018 14:48:00", "17/06/2018 14:49:20",
"17/06/2018 14:50:40", "17/06/2018 14:52:00", "17/06/2018 14:53:20",
"17/06/2018 14:54:40", "17/06/2018 14:56:00", "17/06/2018 14:57:20",
"17/06/2018 14:58:40", "17/06/2018 15:00:00", "17/06/2018 15:01:20",
"17/06/2018 15:02:40", "17/06/2018 15:04:00", "17/06/2018 15:05:20",
"17/06/2018 15:06:40", "17/06/2018 15:08:00", "17/06/2018 15:09:20",
"17/06/2018 15:10:40", "17/06/2018 15:12:00", "17/06/2018 15:13:20",
"17/06/2018 15:14:40", "17/06/2018 15:16:00", "17/06/2018 15:17:20",
"17/06/2018 15:18:40", "17/06/2018 15:20:00", "17/06/2018 15:21:20",
"17/06/2018 15:22:40", "17/06/2018 15:24:00", "17/06/2018 15:25:20",
"17/06/2018 15:26:40", "17/06/2018 15:28:00", "17/06/2018 15:29:20",
"17/06/2018 15:30:40", "17/06/2018 15:32:00", "17/06/2018 15:33:20",
"17/06/2018 15:34:40", "17/06/2018 15:36:00", "17/06/2018 15:37:20",
"17/06/2018 15:38:40", "17/06/2018 15:40:00", "17/06/2018 15:41:20",
"17/06/2018 15:42:40", "17/06/2018 15:44:00", "17/06/2018 15:45:20",
"17/06/2018 15:46:40", "17/06/2018 15:48:00"), ACTIVITY_X = c(34.33333333,
9.666666667, 7.333333333, 14, 19, 23, 21, 21, 21.33333333, 22.66666667,
20.66666667, 17.66666667, 19.66666667, 32.66666667, 51.33333333,
88, 105, 101, 68.33333333, 62.33333333, 85.66666667, 98.33333333,
105.3333333, 91, 107, 99, 92.66666667, 98, 110.6666667, 120,
104, 110.3333333, 132, 148.6666667, 130, 110.6666667, 89.66666667,
92, 88.66666667, 88.66666667, 90.33333333, 100, 100, 87.66666667,
71.33333333, 67.33333333, 65.33333333, 63, 66.66666667, 68.33333333,
67, 63.33333333, 71.66666667, 80.66666667, 95.33333333, 109.6666667,
122.3333333, 110, 84.66666667, 59.66666667, 59, 70.66666667,
86.66666667, 93, 95, 86, 78.66666667, 69, 73.66666667, 72.66666667,
69.66666667, 49, 42.66666667, 43.66666667, 53.33333333, 48.33333333,
46.33333333, 47.66666667, 54.66666667, 58, 54, 52.33333333, 56.66666667,
58, 60.33333333, 62, 72, 83, 94, 93, 98, 82.33333333, 83, 73,
79.66666667, 75.66666667, 63, 45.33333333, 48.33333333, 44.66666667,
44.66666667, 32, 35.33333333, 38, 39.33333333, 42.33333333, 35,
40.66666667, 49.66666667, 71.33333333, 80.33333333, 76.66666667,
66.66666667, 48.66666667, 38.33333333, 46.66666667, 58, 72.33333333,
68, 71.33333333, 65.66666667, 64.66666667, 54.33333333, 52.66666667,
49.66666667, 57.66666667, 64.66666667, 78.66666667, 83.33333333,
86, 83.66666667, 82.66666667, 77.33333333, 68.33333333, 73.33333333,
76, 72, 50, 47, 50.66666667, 59, 48.33333333, 39.33333333, 35,
35.33333333, 40, 37.66666667, 41.66666667, 40.66666667, 37.66666667,
30.33333333, 25, 24, 24.33333333, 25.66666667, 34.33333333, 37,
36.33333333, 31, 35.66666667, 37.33333333, 42, 37, 39.66666667,
38, 41.66666667, 45.66666667, 40.66666667, 38.66666667, 30, 36.33333333,
55.66666667, 60.66666667, 64.33333333, 48.66666667, 49.33333333,
46.33333333, 45, 47.33333333, 51.33333333, 48.33333333, 40.33333333,
32.66666667, 38.33333333, 44, 47, 49.33333333, 44.33333333, 41.66666667,
34.33333333, 37.66666667, 37.66666667, 37.33333333, 35, 30.66666667,
30, 34.66666667, 46.33333333, 55.66666667, 62.66666667, 98.66666667,
118.6666667, 111, 73.33333333, 55, 54.66666667, 53, 50.66666667,
52.33333333, 58, 55.66666667, 62.66666667, 63.33333333, 66, 60,
54, 47, 44, 40.66666667, 46.33333333, 45.66666667, 50, 46, 45.33333333,
44, 38, 36, 36, 40.66666667, 43, 57, 79, 80.66666667, 64, 35.33333333,
33.33333333, 27.33333333, 35, 33, 34.66666667, 27.33333333, 21,
29.66666667, 32.66666667, 43.33333333, 46.33333333, 54, 55, 37.66666667,
20, 7.666666667, 14, 30.66666667, 33, 29, 17.33333333, 14.66666667,
9.333333333, 14.66666667, 17.66666667, 24.66666667, 17, 18.33333333,
26.33333333, 50, 80.66666667, 97.66666667, 107.6666667, 94.33333333,
76.66666667, 64.66666667, 68.33333333, 65.33333333, 51, 30.33333333,
24.66666667, 20.66666667, 22.33333333, 29.33333333, 46), ACTIVITY_Y = c(19.66666667,
7, 4, 9.333333333, 13, 14, 10, 10.66666667, 12.33333333, 17.33333333,
14.33333333, 11.66666667, 11, 25, 57.33333333, 94.66666667, 123,
109.3333333, 76.33333333, 58, 68, 73.66666667, 75, 63, 69, 58,
57.66666667, 70.66666667, 89, 96.66666667, 84.33333333, 92.66666667,
111, 125.3333333, 121.6666667, 120.3333333, 115.6666667, 102.6666667,
102.6666667, 111.6666667, 110, 104.3333333, 91, 85, 79.33333333,
79.66666667, 76, 58.66666667, 57.33333333, 63.66666667, 79, 80,
97.33333333, 98.33333333, 94.66666667, 89, 84.66666667, 111,
95, 92, 70, 95.33333333, 109, 100.3333333, 80.66666667, 69, 75.33333333,
68, 74, 64.33333333, 65.33333333, 40, 34, 32.33333333, 41, 39.66666667,
38.33333333, 38, 40, 41.33333333, 37.66666667, 34.66666667, 49.33333333,
56.33333333, 61, 53, 55.66666667, 79.33333333, 90.33333333, 113,
147, 141.6666667, 128, 70.66666667, 58.33333333, 46.33333333,
47.66666667, 41.66666667, 55.66666667, 50.33333333, 53.66666667,
29.66666667, 34.66666667, 35.33333333, 41.33333333, 45.66666667,
38, 48.33333333, 53, 80, 92, 97.33333333, 75.33333333, 47.66666667,
30.66666667, 56.33333333, 67.66666667, 98, 79, 78.66666667, 62.66666667,
69, 66.33333333, 51.33333333, 56, 90.33333333, 103, 102.6666667,
78.33333333, 80, 81, 73, 62.33333333, 55.33333333, 61.33333333,
64.66666667, 58.33333333, 44.33333333, 47.33333333, 52.33333333,
68.33333333, 53, 39, 21, 22.66666667, 28.66666667, 24.66666667,
26.33333333, 25.33333333, 23.33333333, 21.33333333, 17, 20.33333333,
19.66666667, 20.66666667, 35.33333333, 39, 37, 21, 24.33333333,
27.66666667, 32, 25.33333333, 27, 24.66666667, 25, 28.33333333,
27.33333333, 31, 23, 29.33333333, 57.66666667, 61.33333333, 64,
38, 40, 40, 38, 37.66666667, 34.66666667, 34.33333333, 31, 27,
25.66666667, 31, 33.66666667, 38.66666667, 33, 29.66666667, 21,
21.33333333, 21, 22.66666667, 22.66666667, 21.66666667, 20.66666667,
22, 30.33333333, 50.66666667, 76.33333333, 141.6666667, 169,
151, 87, 45.66666667, 38.33333333, 33.66666667, 32, 31.66666667,
36, 32.33333333, 35.66666667, 38.66666667, 44.33333333, 46, 40.66666667,
32, 26.66666667, 21, 30, 31, 35.66666667, 31.33333333, 28.33333333,
22.66666667, 17, 16, 23.33333333, 31.33333333, 65, 95.33333333,
98, 74, 37.66666667, 29, 23.66666667, 22.33333333, 34.33333333,
39, 45.33333333, 32, 21.33333333, 26, 30.33333333, 37.33333333,
35, 49.33333333, 56.33333333, 42.66666667, 19.33333333, 4.333333333,
8.666666667, 22.33333333, 23.66666667, 21, 9, 6.666666667, 3.666666667,
11.66666667, 15.33333333, 20.66666667, 17, 28.66666667, 46, 76.66666667,
95.66666667, 108, 103.3333333, 90.33333333, 62.66666667, 48.33333333,
52, 52, 40.33333333, 20.33333333, 22.66666667, 21.33333333, 22,
26.66666667, 52), ACTIVITY_Z = c(40, 12.33333333, 8.666666667,
17.33333333, 23.33333333, 27, 23, 23.33333333, 24.66666667, 28.66666667,
25.66666667, 21.66666667, 22.66666667, 41, 77.66666667, 130,
162.6666667, 149.3333333, 103, 85.33333333, 109.6666667, 123.3333333,
129.6666667, 111, 127.6666667, 115, 109.6666667, 121.3333333,
142, 154, 133.6666667, 144, 172.3333333, 194.3333333, 179.3333333,
165, 146.6666667, 138.3333333, 136.3333333, 143.3333333, 143.6666667,
145.6666667, 135.3333333, 122, 107, 104.6666667, 100.6666667,
86.66666667, 88, 93.66666667, 104, 102.3333333, 121, 127.3333333,
136, 142, 149, 160.6666667, 131, 110.3333333, 91.66666667, 119,
139.6666667, 138.6666667, 125.6666667, 111, 109.3333333, 97,
104.6666667, 97.66666667, 96, 63.33333333, 54.66666667, 54.33333333,
67.33333333, 62.33333333, 60, 61, 68, 71.33333333, 65.66666667,
62.66666667, 76, 82, 86.33333333, 82, 91, 115.3333333, 130.6666667,
147.3333333, 179, 164.3333333, 153.6666667, 103, 100.3333333,
89, 80, 61.66666667, 74, 67.33333333, 69.66666667, 43.66666667,
49.66666667, 52, 57, 62.33333333, 52, 63.33333333, 73, 107.3333333,
122.3333333, 124, 102, 69.33333333, 49.33333333, 73.33333333,
89.33333333, 122.6666667, 105.6666667, 108, 91.33333333, 95,
85.66666667, 74, 76, 109.6666667, 123, 132, 114.3333333, 117.6666667,
116.6666667, 110.6666667, 99.66666667, 88.33333333, 96, 100,
92.66666667, 67, 66.66666667, 72.66666667, 90.66666667, 72.66666667,
57, 40.66666667, 42, 49, 45, 49.33333333, 48, 44.66666667, 37.66666667,
31, 31.66666667, 31.33333333, 33, 50, 54.33333333, 52.66666667,
37.66666667, 43.33333333, 46.33333333, 52.66666667, 44.66666667,
48, 45.33333333, 48.66666667, 53.66666667, 49, 49.66666667, 38,
46.66666667, 80.66666667, 87, 91.66666667, 62, 63.66666667, 61.33333333,
59, 60.66666667, 62, 59.33333333, 51, 42.33333333, 46, 53.66666667,
57.66666667, 62.66666667, 55.33333333, 51.33333333, 40.33333333,
43.33333333, 43.33333333, 44, 42, 37.66666667, 36.33333333, 41,
55.33333333, 76.33333333, 99.66666667, 172.6666667, 206.6666667,
187.6666667, 114.3333333, 72, 67, 62.66666667, 60, 61.33333333,
68.66666667, 65, 72.66666667, 75, 80, 75.66666667, 67.66666667,
57.33333333, 52, 46, 55.33333333, 55.33333333, 61.33333333, 55.66666667,
53.33333333, 49.66666667, 41.66666667, 39.66666667, 43.33333333,
51.66666667, 80.66666667, 113, 133.3333333, 113.3333333, 75.33333333,
46, 41, 35.33333333, 49.33333333, 51.33333333, 57.33333333, 42.66666667,
30.33333333, 39.33333333, 44.66666667, 57.33333333, 58.33333333,
74, 79.66666667, 57.66666667, 28.33333333, 9, 16.66666667, 38.33333333,
41, 36, 19.66666667, 16, 10, 19, 23.66666667, 32.33333333, 24.33333333,
34.66666667, 53, 91.66666667, 125.6666667, 146, 149.3333333,
130.6666667, 99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L, 199L, 119L,
39L, 0L, 0L, 0L, 0L, 0L, 0L, 37L, 56L, 56L, 19L, 0L, 0L, 0L,
0L, 58L, 138L, 218L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 179L, 99L, 19L, 0L, 0L, 69L, 149L,
229L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 199L,
119L, 39L, 0L, 0L, 41L, 121L, 201L, 240L, 199L, 119L, 39L, 0L,
79L, 159L, 198L, 133L, 112L, 107L, 173L, 194L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 199L, 119L, 39L, 0L)), row.names = c(NA,
-280L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000000002631ef0>)

We can use:
df[grep(":00$",df$Time),]
Results(truncated for visibility):
head(df[grep(":00$",df$Time),1:4])
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z
1: 17/06/2018 09:36:00 34.33333 19.666667 40.00000
2: 17/06/2018 09:40:00 14.00000 9.333333 17.33333
3: 17/06/2018 09:44:00 21.00000 10.000000 23.00000
4: 17/06/2018 09:48:00 22.66667 17.333333 28.66667
5: 17/06/2018 09:52:00 19.66667 11.000000 22.66667
6: 17/06/2018 09:56:00 88.00000 94.666667 130.00000

Here are a couple ways to do it in base R if you wanted to convert your column to date/time class. I edited it to create needless columns instead of just converting your time column to show different ways to use POSIXt classes. There are pros and cons to using either. From my understanding using lt is usually a little slower but you can access the time elements using $ b/c it is a named list. Check out ?POSIXlt for a better understanding of both
df1$Timelt <- as.POSIXlt(df1$Time, format = "%d/%m/%Y %H:%M:%S")
df1$Timect <- as.POSIXct(df1$Time, format = "%d/%m/%Y %H:%M:%S")
df1[format(df1$Timect, "%S") == "00",]
df1[df1$Timelt$s == 00,]
df1[format(df1$Timelt, "%S") == "00",]
head(df1[df1$Timelt$sec == 00,])
Time ACTIVITY_X ACTIVITY_Y ACTIVITY_Z Vigilance Head-up Grazing Browsing Moving Grooming
1 17/06/2018 09:36:00 34.33333 19.666667 40.00000 0 150 0 35 27 17
4 17/06/2018 09:40:00 14.00000 9.333333 17.33333 0 99 58 0 11 35
7 17/06/2018 09:44:00 21.00000 10.000000 23.00000 0 8 205 0 0 7
10 17/06/2018 09:48:00 22.66667 17.333333 28.66667 0 0 38 0 10 4
13 17/06/2018 09:52:00 19.66667 11.000000 22.66667 0 41 0 0 0 0
16 17/06/2018 09:56:00 88.00000 94.666667 130.00000 7 225 0 0 0 8
Resting Fleeing Unknown End Timelt Timect
1 0 0 11 0 2018-06-17 09:36:00 2018-06-17 09:36:00
4 0 0 37 0 2018-06-17 09:40:00 2018-06-17 09:40:00
7 0 0 20 0 2018-06-17 09:44:00 2018-06-17 09:44:00
10 0 0 77 111 2018-06-17 09:48:00 2018-06-17 09:48:00
13 0 0 0 199 2018-06-17 09:52:00 2018-06-17 09:52:00
16 0 0 0 0 2018-06-17 09:56:00 2018-06-17 09:56:00

Related

How to calculate proportion of zeroes in dataframe by group? Presence/absence proportions

I have data of fish stomach contents (prey items).
In my original df, each fish (with a unique FID) had multiple rows(observations) - one row per unique prey taxon found. For example, if fish #10 had both daphnia and goby in its stomach, there were two rows for that same fish (one row with # of daphnia in that fish's stomach and one row for # of goby in that same stomach); if the fish only had daphnia in their stomach then they had one row; and so on.
I have converted my data from long to wide format to have one observation per row (one unique fish per row).
I am trying to calculate the proportion of empty stomachs by month (when totalnumPrey == 0).
Reproducible data (shortened; complete data has 488 observations):
structure(list(id = c("1001_28", "1001_29", "1001_30", "1001_31",
"1001_32", "1001_33", "1001_34", "1001_35", "1023_3", "614_1",
"614_3", "616_1", "616_3", "616_4", "616_5", "616_6", "824_23",
"824_24", "824_25", "824_26", "824_28", "824_29", "824_30", "824_31",
"824_32", "824_33", "824_35"), CRN = c(1001L, 1001L, 1001L, 1001L,
1001L, 1001L, 1001L, 1001L, 1023L, 614L, 614L, 616L, 616L, 616L,
616L, 616L, 824L, 824L, 824L, 824L, 824L, 824L, 824L, 824L, 824L,
824L, 824L), FID = c(28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
3L, 1L, 3L, 1L, 3L, 4L, 5L, 6L, 23L, 24L, 25L, 26L, 28L, 29L,
30L, 31L, 32L, 33L, 35L), ac = c(2L, 2L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L), mm = c(200L, 159L, 117L, 120L, 108L, 103L, 92L,
97L, 104L, 301L, 163L, 85L, 271L, 290L, 330L, 294L, 270L, 260L,
266L, 197L, 195L, 185L, 160L, 157L, 178L, 166L, 149L), gr = c(95,
44, 15.1, 16.1, 11, 10, 6.9, 7.9, 10.9, 418, 62, 6.8, 311, 453,
593, 395, 283, 275, 261, 96, 90, 90, 56, 50, 57, 62, 45.5), catch = c(2L,
2L, 4L, 4L, 4L, 4L, 2L, 2L, 1L, 3L, 3L, 1L, 5L, 5L, 5L, 5L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 14L), Daphnia = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Byths = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
18L, 79L, 71L, 8L, 73L, 0L, 38L, 39L), Chiro.Pupae = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 255L, 7L, 0L, 576L, 590L, 536L, 576L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Empty = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Chiro.Larvae = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 5L, 38L, 0L, 9L, 0L, 0L, 0L), Amphipod = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 6L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Isopod = c(0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 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L, 23L, 23L, 23L, 23L, 23L, 23L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L), empty = c("Empty",
"Empty", "Empty", "Empty", "Not_empty", "Empty", "Empty", "Empty",
"Not_empty", "Not_empty", "Not_empty", "Empty", "Not_empty",
"Not_empty", "Not_empty", "Not_empty", "Empty", "Empty", "Empty",
"Not_empty", "Not_empty", "Not_empty", "Not_empty", "Not_empty",
"Empty", "Not_empty", "Not_empty")), row.names = c(NA, -27L), class = c("data.table",
"data.frame"))
I haven't been able to figure out a way to calculate proportion using counts instead of actual values (since I need to count the 0 values by group and not use the actual 0 value to calculate the proportion).
I have tried the following:
example %>%
group_by(empty, MONTH) %>%
summarise(totalnumPrey = n()) %>%
mutate(prop = n / sum(n))
This gives the following error:
Error in `mutate()`:
! Problem while computing `prop = n/sum(n)`.
ℹ The error occurred in group 1: empty = "Empty".
Caused by error in `sum()`:
! invalid 'type' (closure) of argument
I also tried this:
transform(example,
perc = ave(totalnumPrey,
empty,
FUN = prop.table))
but this doesn't give me what I need...
Also this:
example %>%
group_by(MONTH) %>%
summarise(n = n()) %>%
mutate(freq = n / sum(n))
which gives me proportion by month, not what I need (i.e. for June it's doing 127/362 = 0.35)...
I have tried many other ways from examples I found in other SO posts but still can't get what I need.
Is there a way I can calculate the proportion of empty vs non-empty stomachs by month?
I also need to do this for each prey type/taxon. For example, proportion of individual fish that contain "Isopod" and so on for each unique taxon in my data. Presence/absence type of proportions.
I mainly want to do this by month first, but will eventually use other groupings.
When I had the data in long format, I was able to calculate proportion of each prey item within one fish stomach by using:
transform(a,
perc = ave(number,
id,
FUN = prop.table))
data not included here.. but 'number' here being the total count of each unique prey taxa/group per stomach/fish & 'id' unique identifier I created to distinguish between different fish (since there were multiple rows for same fish).
I am happy to clarify anything that is not clear or add additional data if needed.
I have searched online and in SO for a few days but still can't figure this out.
Thank you in advance.
I think this is what you need.
What we need to do is to count the number of times the column empty is equal to "Empty" per each group - so we can do this using sum(empty=="Empty") and then divide by the number of rows in that group n().
library(dplyr)
dat %>%
group_by(MONTH) %>%
summarise(
prop_empty = sum(empty=="Empty")/n(),
prop_not_empy = sum(empty != "Empty")/n()
)
# A tibble: 3 × 3
MONTH prop_empty prop_not_empy
<int> <dbl> <dbl>
1 6 0.143 0.857
2 8 0.364 0.636
3 11 0.778 0.222

Kite diagram tidyr

I was following a previous thread (was uncertain if it was inappropriate to post the question there as it is from 2020) and the code produces a kite graph, however, when using my data the axes are swapped and the value I wanted for the x-axis is also included in the wrong group. I want the x-acis to be quadrat number and the y-axis to be species.
Previous thread: Kite Diagram in R
My data looks like this
structure(list(quadrat_number = 0:87, Ulva.sp. = c(12L, 32L,
24L, 28L, 48L, 16L, 80L, 24L, 80L, 100L, 16L, 32L, 40L, 40L,
68L, 56L, 28L, 32L, 20L, 8L, 24L, 12L, 0L, 20L, 56L, 32L, 72L,
48L, 76L, 68L, 20L, 88L, 88L, 0L, 56L, 12L, 12L, 32L, 100L, 28L,
0L, 0L, 4L, 44L, 80L, 100L, 100L, 0L, 88L, 96L, 100L, 0L, 0L,
0L, 0L, 0L, 0L, 32L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L), Hormosira = c(0L, 72L, 24L, 32L, 0L, 0L, 52L,
8L, 24L, 80L, 4L, 16L, 12L, 16L, 60L, 16L, 12L, 0L, 0L, 0L, 32L,
8L, 0L, 64L, 0L, 8L, 24L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L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 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), Pyropia.cinnamomea = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 12L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 8L, 20L, 52L, 0L,
4L, 0L, 0L, 24L, 40L, 12L)), class = "data.frame", row.names = c(NA,
-88L))
I followed the code on the other thread.
library(plotrix)
kiteChart(dataprune)
library(dplyr)
library(tidyr)
dataprune <- as.data.frame(dataprune) %>% mutate(species = rownames(dataprune)) %>%
pivot_longer(-species, names_to = "X_var", values_to = "values") %>%
mutate(species = factor(species, levels = unique(species))) %>%
mutate(X_var = factor(X_var, levels = unique(X_var))) %>%
mutate(NewY = as.numeric(species)*2) %>%
mutate(normval = values / max(values)) %>%
mutate(NewX = as.numeric(X_var))
ggplot(dataprune, aes(x = NewX, fill = species))+
geom_ribbon(aes(ymin = NewY-normval, ymax = NewY+normval))+
scale_y_continuous(breaks = unique(dataprune$NewY), labels = levels(dataprune$species))+
scale_x_continuous(breaks = unique(dataprune$NewX), labels = levels(dataprune$X_var), name = "")
This produced this graph
not correct kite diagram
On the other thread they got a graph like this.
ideal graph
I think the issue is in the creation of the variables but I'm not sure what to do or how to arrange my data so it'd work in this frame.
If this wasn't clear please tell me. Thanks so much
The problem is your data is in the wrong shape for kitePlot(). You need to make the y-axis variables the row names and the x-axis variables the column names.
Here's an approach with tidyr:
library(tidyverse)
library(plotrix)
dataprune %>%
pivot_longer(-quadrat_number, names_to = "organism") %>%
pivot_wider(names_from = quadrat_number, values_from = value) %>%
column_to_rownames("organism") -> reshaped.dataprune
reshaped.dataprune[,1:5]
# 0 1 2 3 4
#Ulva.sp. 12 32 24 28 48
#Hormosira 0 72 24 32 0
#Bostrychia 92 0 0 40 0
#Corallina.crustose 0 4 4 4 0
#Jania 0 0 0 0 0
#Pyropia.cinnamomea 0 0 0 0 0
kiteChart(reshaped.dataprune)

"object ... not found" with randomForest

I am quite new to R world. I'm currently working on a flight delay prediction.
I'm getting "object 'date01-01-2004' not found" even though it is present.
I tried converting all the factors into dummy variables and doing random forest on it.
library(caret)
library(dummies)
library(randomForest)
flight<-read.csv("E:\\Rdata\\FlightDelays.csv",header = TRUE)
summary(flight$dest)
summary(flight$carrier)
plot(flight$delay~flight$carrier,ylab="delay",xlab="carrier")
plot(flight$delay~flight$dest,ylab="delay",xlab="destination")
plot(flight$delay~flight$origin,ylab="delay",xlab="origin")
plot(flight$delay~flight$dayweek,ylab="delay",xlab="dayweek")
str(flight)
flight$tailnu<-NULL
fl1<-flight$delay
flight$delay<-NULL
flight<-dummy.data.frame(data=flight)
dput(head(flight,50))
flight$delay<-fl1
rf1<-randomForest(delay~.,data=flight)
The output should not be an error and random forest computed one.But I'm getting following output even though it contains date01-01-200 .
structure(list(schedtime = c(1455L, 1640L, 1245L, 1715L, 1039L,
840L, 1240L, 1645L, 1715L, 2120L, 2120L, 1455L, 930L, 1230L,
1430L, 1730L, 2030L, 1530L, 600L, 1830L, 900L, 1300L, 1400L,
1500L, 1900L, 850L, 900L, 1100L, 1300L, 1500L, 1700L, 2100L,
1455L, 1720L, 1030L, 700L, 1300L, 1730L, 840L, 1710L, 1245L,
2120L, 1700L, 1900L, 1525L, 1900L, 1400L, 1515L, 1300L, 1630L
), carrierCO = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L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, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), carrierUA = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), carrierUS = c(0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), deptime = c(1455L,
1640L, 1245L, 1709L, 1035L, 839L, 1243L, 1644L, 1710L, 2129L,
2114L, 1458L, 932L, 1228L, 1429L, 1728L, 2029L, 1525L, 556L,
1822L, 853L, 1254L, 1356L, 1452L, 1853L, 841L, 858L, 1056L, 1253L,
1458L, 1655L, 2055L, 1452L, 1710L, 1030L, 656L, 1256L, 1726L,
840L, 1704L, 1245L, 2118L, 1651L, 1850L, 1521L, 1855L, 1357L,
1508L, 1255L, 1625L), destEWR = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), destJFK = c(1L,
1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), destLGA = c(0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), distance = c(184L, 213L, 229L, 229L,
229L, 228L, 228L, 228L, 228L, 228L, 229L, 213L, 214L, 214L, 214L,
214L, 214L, 213L, 213L, 213L, 214L, 214L, 214L, 214L, 214L, 229L,
214L, 214L, 214L, 214L, 214L, 214L, 169L, 169L, 169L, 169L, 199L,
199L, 213L, 213L, 213L, 213L, 213L, 213L, 199L, 199L, 199L, 213L,
213L, 199L), `date01-01-2004` = c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), `date01-02-2004` = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), `date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 7792L, 7800L, 7806L, 7810L, 7812L, 7814L,
7924L, 746L, 1746L, 1752L, 1756L, 1762L, 1768L, 4752L, 4760L,
4784L, 4956L, 4964L, 4966L, 4968L, 4976L, 846L, 2164L, 2168L,
2172L, 2176L, 2180L, 2188L, 2403L, 2675L, 2303L, 2703L, 808L,
814L, 7299L, 7302L, 7303L, 7304L, 2497L, 2385L, 2261L, 2336L,
2216L, 2156L, 2664L, 2181L), originBWI = c(1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), originDCA = c(0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L,
1L), originIAD = c(0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L,
1L, 0L, 0L, 0L, 1L, 1L, 0L), weather = c(0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), dayweek = c(4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L), daymonth = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("schedtime", "carrierCO",
"carrierDH", "carrierDL", "carrierMQ", "carrierOH", "carrierRU",
"carrierUA", "carrierUS", "deptime", "destEWR", "destJFK", "destLGA",
"distance", "date01-01-2004", "date01-02-2004", "date01-03-2004",
"date01-04-2004", "date01-05-2004", "date01-06-2004", "date01-07-2004",
"date01-08-2004", "date01-09-2004", "date01-10-2004", "date01-11-2004",
"date01-12-2004", "date1/13/2004", "date1/14/2004", "date1/15/2004",
"date1/16/2004", "date1/17/2004", "date1/18/2004", "date1/19/2004",
"date1/20/2004", "date1/21/2004", "date1/22/2004", "date1/23/2004",
"date1/24/2004", "date1/25/2004", "date1/26/2004", "date1/27/2004",
"date1/28/2004", "date1/29/2004", "date1/30/2004", "date1/31/2004",
"flightnumber", "originBWI", "originDCA", "originIAD", "weather",
"dayweek", "daymonth"), dummies = structure(list(carrier = 2:9,
dest = 11:13, date = 15:45, origin = 47:49), .Names = c("carrier",
"dest", "date", "origin")), row.names = c("1", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48",
"49", "50"), class = "data.frame")
Error in eval(predvars, data, env) : object 'date01-01-2004' not found
My guess (strongly supported by the example below) is that randomForest() can't handle non-syntactic variable/column names, i.e. ones with spaces or punctuation other than dots in them. You could try names(flight) <- make.names(names(flight)) to fix this. It's surprising that read.csv() didn't already fix the names for you: are you sure you didn't use readr::read_csv() instead?
library(randomForest)
## make up random frame with OK names
dd <- data.frame(y=rnorm(1000),x1=rnorm(1000),x2=rnorm(1000))
r1 <- randomForest(y~., data=dd) ## this works fine
Now modify the names to include a predictor with dashes in its name:
names(dd)[3] <- "a-b-c"
r2 <- randomForest(y~., data=dd)
Error in eval(predvars, data, env) : object 'a-b-c' not found
Now fix the names using make.names():
names(dd) <- make.names(names(dd))
r3 <- randomForest(y~., data=dd) ## works
What did make.names() do?
names(dd)
## [1] "y" "x1" "a.b.c"

Extract n rows before and after a value in a data frame

I have a data frame with certain values in a Mark column. I want to extract n values before and after a mark occurs (including the row with the mark).
I find the values I need by using indices <- which(df$Mark == 1) where 1 is the value I'm looking for. Now I need for example the indices of 5 rows before that and 5 rows after (and the one with the mark, so 11 rows in total).
I was thinking about looping through the indices to increase and decrease it by n, and then to subset the data frame with the appended indices. It would be quite nasty though.
Is there a faster way to do it? e.g. in dplyr? Base R answer will be fine as well.
PS: I read the similar question but it doesn't seem to fit my problem.
Here's the df:
df <- structure(list(CH1 = c(-0.02838132, -0.02642141, -0.02511601,
-0.02443906, -0.02414024, -0.02417388, -0.02451562, -0.02393946,
-0.02242496, -0.02104852, -0.0198534, -0.018965, -0.01853905,
-0.01837877, -0.01857743, -0.01847437, -0.0176798, -0.01672419,
-0.01594565, -0.01522826, -0.01485198, -0.01484227, -0.01507997,
-0.01556828, -0.01534458, -0.01473233, -0.01376753, -0.01251296,
-0.0116294, -0.01064516, -0.00966026, -0.00970934, -0.00969434,
-0.00921217, -0.00881855, -0.00832315, -0.00793322, -0.00718289,
-0.00643288, -0.00574532, -0.00535603, -0.00503564, -0.00469125,
-0.00449608, -0.00426023, -0.00406978, -0.00401041, -0.00293273,
-0.00154294, -0.0012401, -0.00108466, -0.00116468, -0.00121755,
-0.00127168, -0.00099938, 0.00017319, 0.0019737, 0.00333815,
0.00396771, 0.00439491, 0.00482015, 0.00515174, 0.0054591, 0.00657748,
0.00863549, 0.01048496, 0.01175601, 0.01272887, 0.01350854, 0.0140988,
0.01475749, 0.01568579, 0.0178412, 0.02036553, 0.02206326, 0.02315541,
0.0241971, 0.02509713, 0.02599812, 0.02695202, 0.02829221, 0.03048931,
0.03233365, 0.03385062, 0.03544046, 0.03690707, 0.03846173, 0.03980747,
0.04145224, 0.04344824, 0.04491818, 0.04621653, 0.04728952, 0.04851875,
0.04968494, 0.05085734, 0.05207405, 0.05288386, 0.05377864, 0.05486108,
0.05593761, 0.0570737, 0.05811917, 0.0593426, 0.06005302, 0.05993605,
0.05984828, 0.06032347, 0.06089914, 0.06177185, 0.06246712, 0.06323557,
0.06413276, 0.06416812, 0.06303713, 0.06264461, 0.06301019, 0.06348586,
0.06426832, 0.06509175, 0.06570335, 0.06598329, 0.06489886, 0.06344099,
0.06281661, 0.06292738, 0.0630922, 0.06334323, 0.06376194, 0.0640305,
0.06399924, 0.06292669, 0.06141425, 0.06046086, 0.06002845, 0.05977921,
0.05952547, 0.05947563, 0.05888767, 0.05753626, 0.05571093, 0.05391346,
0.053135, 0.05240138, 0.05196891, 0.05157123, 0.05107314, 0.05004111,
0.04812315, 0.04601065, 0.04457145, 0.04376672, 0.04318091, 0.04265054,
0.04222059, 0.041618, 0.0403326, 0.03810122, 0.03623468, 0.03515417,
0.0343935, 0.03381848, 0.03330182, 0.03288956, 0.03268627, 0.03136984,
0.02941283, 0.02847409, 0.02766387, 0.0268678, 0.02645577, 0.02606292,
0.02592612, 0.0258327, 0.02477442, 0.02381663, 0.02342893, 0.02307516,
0.02289283, 0.02281655, 0.02268435, 0.02245292, 0.02224212, 0.02203094,
0.02189966, 0.02157357, 0.02129673, 0.02102508, 0.02140636, 0.02188274,
0.02238155, 0.02332248, 0.02454547, 0.02617604, 0.0281874, 0.03046315,
0.03274331, 0.03508138, 0.03754183, 0.04001183, 0.04252412, 0.04485972,
0.04726444, 0.04945699, 0.05171933, 0.05405642, 0.05621058, 0.05858717,
0.06119974, 0.0631874, 0.06494498, 0.06654966, 0.06778654, 0.06895418,
0.0702159, 0.07208018, 0.07471886, 0.07640609, 0.07795521, 0.07929013,
0.08029186, 0.08135373, 0.08218034, 0.08313267, 0.08513113, 0.08683419,
0.08791834, 0.08894015, 0.08975692, 0.09043255, 0.09113128, 0.09186111,
0.09291916, 0.09414985, 0.09492029, 0.09583852, 0.09664483, 0.09738685,
0.09791321, 0.09827693, 0.09842386, 0.09819575, 0.09783525, 0.09711579,
0.09588714, 0.09464117, 0.09342161, 0.09221725, 0.09094498, 0.08979087,
0.08813678, 0.08722136, 0.08660734, 0.0863056, 0.08614786, 0.08576027,
0.08508192, 0.08408207, 0.08224716, 0.0805236, 0.0793857, 0.07835744,
0.07776693, 0.07704602, 0.0762578, 0.0748622, 0.07237066, 0.06983608,
0.06798425, 0.06677078, 0.0660528, 0.06569698, 0.06521391, 0.06434717,
0.06249718, 0.06009818, 0.05800739, 0.05674874, 0.05583431, 0.05525231,
0.05479279, 0.05451269, 0.05392969, 0.05218898, 0.05015828, 0.04889652,
0.04834132, 0.04789649, 0.04757991, 0.04729923, 0.04713846, 0.04664839,
0.044963, 0.0434754, 0.04290805, 0.04229798, 0.04186826, 0.04133299,
0.04069157, 0.03980917, 0.03850414, 0.03609292, 0.03422226, 0.03281199,
0.03131085, 0.03030436, 0.02957696, 0.02881902, 0.02801267, 0.0266918,
0.02524513, 0.02468021, 0.02422629, 0.02412119, 0.02414609, 0.02431383,
0.02445115, 0.02420395, 0.02307613, 0.0225228, 0.02239294, 0.02228146,
0.02247078, 0.02297619, 0.02339916, 0.02380192, 0.02367893, 0.02331219,
0.02357285, 0.0239001, 0.02413282, 0.02442478, 0.02460252, 0.02484779,
0.02539408, 0.02547098, 0.02568989, 0.02612677, 0.02653343, 0.02691505,
0.02732947, 0.02783551, 0.02845577, 0.0294369, 0.03000503, 0.0303594,
0.03106044, 0.03183592, 0.03254643, 0.03336877, 0.03433665, 0.03611183,
0.03759354, 0.03864425, 0.03966344, 0.04067133, 0.04175726, 0.04283931,
0.04391302, 0.04588513, 0.04825597, 0.04982677, 0.05137081, 0.05256286,
0.05363528, 0.05468207, 0.05576433, 0.05764562, 0.06039843, 0.06209074,
0.06330606, 0.06437107, 0.06532845, 0.06612719, 0.06689882, 0.06780636,
0.06962782, 0.07139035, 0.07266567, 0.07378628, 0.07471222, 0.07541681,
0.07637413, 0.07729325, 0.07797043, 0.07928976, 0.08020929, 0.08104116,
0.08185486, 0.08268223, 0.08352671, 0.08418175, 0.08467345, 0.0845037,
0.08452599, 0.08504328, 0.08524517, 0.08562133, 0.08602719, 0.08630189,
0.08619381, 0.08511638, 0.08378159, 0.08298928, 0.08275849, 0.08255187,
0.08253576, 0.08248511, 0.08237054, 0.08131169, 0.07927644, 0.07758952,
0.07666323, 0.07611373, 0.07583219, 0.07563592, 0.07526416, 0.07413918,
0.07218219, 0.07052977, 0.06947646, 0.06885928, 0.06852632, 0.06836134,
0.06829559, 0.06804968, 0.06684561, 0.06508074, 0.06383415, 0.06333059,
0.06309205, 0.06312215, 0.06308869, 0.06325907, 0.06330066, 0.06230686,
0.06121331, 0.06093323, 0.06080826, 0.06103985, 0.06129866, 0.0616675,
0.06222659, 0.06271791, 0.06269919, 0.06317165, 0.06388476, 0.06443688,
0.06532656, 0.06643683, 0.06762666, 0.0688545, 0.06957003, 0.07049679,
0.07145847, 0.07254429, 0.07379688, 0.07520389, 0.07666438, 0.07813754,
0.07980724, 0.08164999, 0.08337331, 0.0850293, 0.08675431, 0.08850279,
0.0903589, 0.09223478, 0.09399396, 0.09617301, 0.09825616, 0.1001754,
0.10215286, 0.10405939, 0.10593522, 0.10771114, 0.10955779, 0.11137673,
0.11350922, 0.11566091, 0.11786379, 0.1201627, 0.12245044, 0.12446617,
0.12668717, 0.12880468, 0.13083965, 0.13320723, 0.13573529, 0.13813868,
0.14067729, 0.14306904, 0.14548148, 0.14758988, 0.14929967, 0.150388,
0.15233791, 0.15449043, 0.15652253, 0.15867107, 0.16075753, 0.16281015,
0.16490422, 0.16620035, 0.16787185, 0.16964339, 0.17125645, 0.17307489,
0.17497104, 0.1767696, 0.17835094, 0.1791379, 0.17976147, 0.18114665,
0.18252681, 0.18401302, 0.18556376, 0.18716799, 0.18869627, 0.18947925,
0.18952475, 0.19017635, 0.19119224, 0.19240457, 0.19406083, 0.19560736,
0.19702311, 0.19838278, 0.19857232, 0.19853884, 0.19905365, 0.19978584,
0.20052382, 0.20136617, 0.20214938, 0.20287189, 0.20312707, 0.20246537,
0.20244905, 0.20259959, 0.20278233, 0.20327239, 0.20340601, 0.20375103,
0.20409654, 0.2038635, 0.20327988, 0.20336974, 0.20360702, 0.20394714,
0.20437293, 0.20460138, 0.20475748, 0.20456536, 0.20375752, 0.20371552,
0.20368604, 0.20359299, 0.2035453, 0.20345831, 0.20340526, 0.20343742,
0.20276403, 0.20228943, 0.20203541, 0.20188482, 0.2018925, 0.20187522,
0.20192079, 0.20182329, 0.20151561, 0.20119683, 0.20101932, 0.20076922,
0.20026171, 0.19982927, 0.19950271, 0.19908488, 0.19889168, 0.19908054,
0.19908604, 0.19869895, 0.1984064, 0.1980564, 0.19761464, 0.19729775,
0.19710955, 0.1974078, 0.19742712, 0.19735026, 0.19726095, 0.19695149,
0.19679484, 0.19663087, 0.19647489, 0.19718868, 0.19785891, 0.19784996,
0.19788255, 0.19757998, 0.19728665, 0.19721918, 0.19730429, 0.19846697,
0.19968045, 0.19982629, 0.20010276, 0.20030209, 0.20027906, 0.2004303,
0.20071957, 0.20170523, 0.20357136, 0.20445201, 0.20511229, 0.2053825,
0.20552762, 0.2057181, 0.20584874, 0.20681113, 0.20865934, 0.20982285,
0.21037306, 0.21086055, 0.21114743, 0.21141832, 0.21172704, 0.21270722,
0.21425499, 0.21508047, 0.21540311, 0.21570137, 0.21566178, 0.2157706,
0.2157407, 0.21586709, 0.21686926, 0.21775885, 0.21800305, 0.21835183,
0.21890219, 0.21994038, 0.22143123, 0.22224599, 0.22288845, 0.22398168,
0.22474541, 0.22512311, 0.22491746, 0.2245485, 0.22401106, 0.22340615,
0.22256076, 0.22140816, 0.22045675, 0.21932106, 0.21813713, 0.21674703,
0.21546952, 0.21415956, 0.21265213, 0.21120454, 0.20967419, 0.2082095,
0.20655277, 0.20475774, 0.20279387, 0.20076135, 0.19890919, 0.19709851,
0.19524029, 0.19323021, 0.19112383, 0.18902898, 0.18701997, 0.18506767,
0.18315709, 0.18136762, 0.17967033, 0.1778329, 0.17634939, 0.17506276,
0.17422849, 0.17365934, 0.17368531, 0.17453934, 0.17546247, 0.17564483,
0.17587478, 0.17576717, 0.17500107, 0.1736709, 0.17258336, 0.17265072,
0.17284319, 0.17171922, 0.16994849, 0.16780928, 0.16595082, 0.16508843
), Mark = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 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0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("CH1",
"Mark"), row.names = c(NA, 700L), class = "data.frame")
You don't need dplyr, you can use indexing in base R.
inds = which(df$Mark == 1)
# We use lapply() to get all rows for all indices, result is a list
rows <- lapply(inds, function(x) (x-5):(x+5))
# With unlist() you get all relevant rows
df[unlist(rows),]
I just solved a similar problem with the shift function from data.table. Basically I use shift in the i statement of the data table:
library(data.table)
df[Mark == 1 | shift(Mark==1, n=5L, type = "lag") | shift(search==1, n=5L, type = "lead")]
I always find data.table to be really intuitive.

R error in '[<-.data.frame'... replacement has # items, need #

I am new to R and this one is beyond me. The script below uses two dummy tables (result and count) each with two columns (A and B). I'm running permutations tests to compare the results from A and B. Specifically, I'm looking at result/count for A and B. Both result and count have 20 rows and I've written a loop to run a permutation test for the first 10 rows of each, then the first 11, then 12, up to 20. When it works, which it does on occasion, I get a pretty graph at the end.
#Set up the dummy data - two competing tables (result & count)
result <- data.frame(matrix(runif(40)*100, nrow=20))
names(result)[1] <- paste("A"); names(result)[2] <- paste("B")
count <- data.frame(matrix(runif(40)*100, nrow=20))
names(count)[1] <- paste("A"); names(count)[2] <- paste("B")
n.iter <- 1e3
#Run a permutation test
permtest <- function(result, count) {
n <- dim(result)[1]
# print(n)
stat <- function(x, y) abs(diff(range(colSums(x)/colSums(y))))
swap <- function(x, i) { x[i, ] <- cbind(x[, "B"], x[, "A"])[i, ]; return (x) }
sim <- replicate(n.iter, { i <- runif(n) < 1/2; stat(swap(result, i), swap(count, i)) })
result.stat <- stat(result, count)
p.value <- sum(sim >= result.stat) / length(sim)
return(list(sim, result.stat, p.value))
}
#Compute evolution of p-values over time
p.evol <- data.frame()
for (i in 10:dim(result)[1]) {
# print(i)
permresults <- permtest(result[1:i,], count[1:i,])
p.value <- permresults[[3]]
p.evol <- rbind(p.evol, c(i, p.value, 1-p.value))
}
colnames(p.evol) <- c("day", "p.value", "conf")
dev.new()
plot(p.evol[,1],p.evol[,3], type="b", xlab="Day",ylab="Percentage", main="Evolution of Confidence")
The problem is that while sometimes it runs no problem, most of the time I get Error in '[<-.data.frame'('*tmp*', i, , value = numeric(0)) : replacement has 0 items, need 24. With options(error=traceback) I get the output here, which I am not understanding:
f(ngettext(m, "replacement has %d item, need %d",
"replacement has %d items, need %d"), m, n * p), domain = NA)
16: `[<-.data.frame`(`*tmp*`, i, , value = numeric(0)) at errortest.R#16
15: `[<-`(`*tmp*`, i, , value = numeric(0)) at errortest.R#16
14: swap(result, i)
13: is.data.frame(x)
12: colSums(x)
11: diff(range(colSums(x)/colSums(y))) at errortest.R#15
10: stat(swap(result, i), swap(count, i)) at errortest.R#17
9: FUN(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,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 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)[[42L]], ...)
8: lapply(X = X, FUN = FUN, ...)
7: sapply(integer(n), eval.parent(substitute(function(...) expr)),
simplify = simplify)
6: replicate(n.iter, {
i <- runif(n) < 1/2
stat(swap(result, i), swap(count, i))
}) at errortest.R#17
5: permtest(result[1:i, ], count[1:i, ]) at errortest.R#27
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("errortest.R", echo = F)
What is particularly puzzling is that it works sometimes! How is this possible? I've also noticed that when I un-comment print(n) and print(i) it seems to make it work more frequently, although it can fail when they are not commented and work when they are. Thanks in advance for the help!
This error pops up when you're unlucky and i <- runif(n) < 1/2 consists only of FALSE, i.e. no permutations happen. You need to add a check in the swap function to fix this problem.

Resources