У меня есть фрейм данных:
EEG Recording
1 18.071 AA00
2 18.703 AA00
3 19.644 AA00
4 20.090 AA00
5 20.534 AA00
6 20.758 AA00
7 21.178 AA00
8 21.778 AA00
9 22.278 AA00
10 22.611 AA00
11 22.946 AA00
12 23.414 AA00
13 23.718 AA00
14 24.072 AA00
15 24.454 AA00
16 25.090 AA00
17 25.545 AA00
18 25.802 AA00
19 26.191 AA00
20 26.500 AA00
21 26.890 AA00
22 27.128 AA00
23 27.522 AA00
24 28.159 AA00
25 28.718 AA00
26 29.151 AA00
27 29.301 AA00
28 29.954 AA00
29 30.374 AA00
30 30.821 AA00
31 31.311 AA00
32 31.817 AA00
33 32.051 AA00
34 32.405 AA00
35 32.652 AA00
36 33.025 AA00
37 33.325 AA00
38 33.605 AA00
39 34.164 AA00
40 34.668 AA00
41 35.004 AA00
42 35.442 AA00
43 35.962 AA00
44 36.481 AA00
45 36.924 AA00
46 37.131 AA00
47 37.316 AA00
48 37.728 AA00
49 38.183 AA00
50 38.756 AA00
51 39.270 AA00
52 39.814 AA00
53 40.382 AA00
54 41.564 AA00
55 41.985 AA00
56 42.541 AA00
57 42.926 AA00
58 43.282 AA00
59 43.848 AA00
60 44.315 AA00
61 44.920 AA00
62 45.095 AA00
63 45.607 AA00
64 46.047 AA00
65 46.465 AA00
66 46.901 AA00
67 47.223 AA00
68 47.524 AA00
69 47.793 AA00
70 48.027 AA00
71 48.479 AA00
72 48.945 AA00
73 49.904 AA00
74 50.413 AA00
75 50.957 AA00
76 51.356 AA00
77 51.903 AA00
78 52.353 AA00
79 52.873 AA00
80 53.235 AA00
81 53.539 AA00
82 53.785 AA00
83 54.135 AA00
84 54.525 AA00
85 54.856 AA00
86 55.260 AA00
87 55.497 AA00
88 55.746 AA00
89 56.277 AA00
90 56.738 AA00
91 57.159 AA00
92 57.550 AA00
93 57.817 AA00
94 58.138 AA00
95 58.547 AA00
96 59.035 AA00
97 59.511 AA00
98 60.035 AA00
99 60.501 AA00
100 60.806 AA00
101 61.159 AA00
102 61.459 AA00
103 61.708 AA00
104 62.171 AA00
105 62.678 AA00
106 62.919 AA00
107 63.285 AA00
108 63.541 AA00
109 63.972 AA00
110 64.527 AA00
111 65.015 AA00
112 65.413 AA00
113 65.888 AA00
114 66.271 AA00
115 66.505 AA00
116 66.723 AA00
117 66.941 AA00
118 67.378 AA00
119 67.896 AA00
120 68.359 AA00
121 68.717 AA00
122 68.976 AA00
123 69.326 AA00
124 69.625 AA00
125 69.782 AA00
126 70.016 AA00
127 70.946 AA00
128 71.520 AA00
129 71.953 AA00
130 72.350 AA00
131 72.896 AA00
132 73.193 AA00
133 73.528 AA00
134 73.999 AA00
135 74.295 AA00
136 74.713 AA00
137 75.236 AA00
138 75.732 AA00
139 75.953 AA00
140 76.348 AA00
141 76.739 AA00
142 77.063 AA00
143 77.289 AA00
144 77.849 AA00
145 78.369 AA00
146 78.848 AA00
147 79.395 AA00
148 79.888 AA00
149 80.372 AA00
150 80.672 AA00
151 80.880 AA00
152 81.351 AA00
153 81.452 AA00
154 81.847 AA00
155 82.350 AA00
156 82.786 AA00
157 83.193 AA00
158 83.557 AA00
159 83.977 AA00
160 84.541 AA00
161 85.246 AA00
162 85.828 AA00
163 86.206 AA00
164 86.885 AA00
165 87.128 AA00
166 88.162 AA00
167 88.540 AA00
168 88.891 AA00
169 89.095 AA00
170 89.576 AA00
171 90.153 AA00
172 90.707 AA00
173 91.267 AA00
174 91.674 AA00
175 92.152 AA00
176 92.412 AA00
177 92.744 AA00
178 93.277 AA00
179 93.850 AA00
180 95.546 AA00
181 96.149 AA00
182 96.482 AA00
183 96.860 AA00
184 97.253 AA00
185 97.538 AA00
186 97.782 AA00
187 98.142 AA00
188 98.424 AA00
189 98.827 AA00
190 99.651 AA00
191 100.134 AA00
192 100.456 AA00
193 100.749 AA00
194 101.274 AA00
195 101.794 AA00
196 102.242 AA00
197 102.722 AA00
198 103.113 AA00
199 103.423 AA00
200 103.900 AA00
Я хочу убедиться, что никакие значения в all_eeg $ EEG не ближе, чем 0,25 друг к другу. Я попытался написать al oop, в котором значение индекса вычитается из последующего значения индекса, чтобы узнать, меньше ли оно или равно 0,25.
for(i in 1:nrow(all_eeg)){
if(all_eeg$EEG[i] - all_eeg$EEG[i+1] <= 0.25){
all_eeg$EEG[i] <- NA
}
}
Я получаю эту ошибку:
Error in if ((all_eeg$EEG[i] - all_eeg$EEG[i + 1]) <= 0.25) { :
missing value where TRUE/FALSE needed
Может быть [i + 1] неправильный. Я не знаю. Надеюсь, ты сможешь мне помочь!