Apple M2 Macbook Pro Segmentation Fault using uWSGI and requests library - python-requests

I have a project with the following set-up and I'm encountering a Segmentation Fault. Has someone encountered this or something similar and was able to fix it?
Computer: Apple Macbook Pro M2
Pyenv, python, version 3.10.5,
openssl#1.1,
Django==4.1.1,
requests==2.28.1,
uwsgi==2.0.20,
uswgi ini file:
processes = 1
enable-threads = true
single-interpreter = true
http = 127.0.0.1:8080
socket = 127.0.0.1:8081
master = true
python-auto-reload = 1
thunder-lock = true
max-requests = 5000
harakiri = 1200
buffer-size = 65535
disable-logging = true
If I change master into false, then there isn't any segmentation fault anymore. The segmentation fault is triggered when the requests library makes any type of request, so I am imagining that the issue is either with uwsgi, the requests library, or openssl
Segfault message reads:
!!! uWSGI process 94052 got Segmentation Fault !!!
*** backtrace of 94052 ***
0 uwsgi 0x0000000100c89398 uwsgi_backtrace + 52
1 uwsgi 0x0000000100c898ac uwsgi_segfault + 56
2 libsystem_platform.dylib 0x00000001b04b42a4 _sigtramp + 56
3 libsystem_trace.dylib 0x00000001b022e098 _os_log_preferences_refresh + 36
4 libsystem_trace.dylib 0x00000001b022eae0 os_log_type_enabled + 644
5 CoreFoundation 0x00000001b05199c8 -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 204
6 CoreFoundation 0x00000001b05198dc -[CFPrefsSource copyValueForKey:] + 52
7 CoreFoundation 0x00000001b0519890 __76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke + 32
8 CoreFoundation 0x00000001b0511f44 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 376
9 CoreFoundation 0x00000001b068c734 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 384
10 CoreFoundation 0x00000001b0511818 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 168
11 CoreFoundation 0x00000001b0511734 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 112
12 SystemConfiguration 0x00000001b10e08cc SCDynamicStoreCopyProxiesWithOptions + 180
13 _scproxy.cpython-310-darwin.so 0x000000010215b85c get_proxy_settings + 44
14 libpython3.10.dylib 0x00000001011ca2ec cfunction_vectorcall_NOARGS + 332
15 libpython3.10.dylib 0x0000000101264b9c call_function + 316
16 libpython3.10.dylib 0x0000000101262204 _PyEval_EvalFrameDefault + 25452
17 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
18 libpython3.10.dylib 0x0000000101264b9c call_function + 316
19 libpython3.10.dylib 0x0000000101262204 _PyEval_EvalFrameDefault + 25452
20 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
21 libpython3.10.dylib 0x0000000101264b9c call_function + 316
22 libpython3.10.dylib 0x0000000101262204 _PyEval_EvalFrameDefault + 25452
23 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
24 libpython3.10.dylib 0x0000000101264b9c call_function + 316
25 libpython3.10.dylib 0x000000010126227c _PyEval_EvalFrameDefault + 25572
26 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
27 libpython3.10.dylib 0x0000000101264b9c call_function + 316
28 libpython3.10.dylib 0x000000010126227c _PyEval_EvalFrameDefault + 25572
29 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
30 libpython3.10.dylib 0x0000000101264b9c call_function + 316
31 libpython3.10.dylib 0x0000000101262154 _PyEval_EvalFrameDefault + 25276
32 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
33 libpython3.10.dylib 0x00000001011846e8 method_vectorcall + 168
34 libpython3.10.dylib 0x0000000101182430 PyVectorcall_Call + 144
35 libpython3.10.dylib 0x00000001012624a4 _PyEval_EvalFrameDefault + 26124
36 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
37 libpython3.10.dylib 0x0000000101182430 PyVectorcall_Call + 144
38 libpython3.10.dylib 0x00000001012624a4 _PyEval_EvalFrameDefault + 26124
39 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
40 libpython3.10.dylib 0x0000000101264b9c call_function + 316
41 libpython3.10.dylib 0x000000010126227c _PyEval_EvalFrameDefault + 25572
42 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
43 libpython3.10.dylib 0x00000001011846e8 method_vectorcall + 168
44 libpython3.10.dylib 0x0000000101264b9c call_function + 316
45 libpython3.10.dylib 0x000000010126227c _PyEval_EvalFrameDefault + 25572
46 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
47 libpython3.10.dylib 0x00000001011846e8 method_vectorcall + 168
48 libpython3.10.dylib 0x0000000101264b9c call_function + 316
49 libpython3.10.dylib 0x000000010126227c _PyEval_EvalFrameDefault + 25572
50 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
51 libpython3.10.dylib 0x0000000101182430 PyVectorcall_Call + 144
52 libpython3.10.dylib 0x00000001012624a4 _PyEval_EvalFrameDefault + 26124
53 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
54 libpython3.10.dylib 0x0000000101182430 PyVectorcall_Call + 144
55 libpython3.10.dylib 0x00000001012624a4 _PyEval_EvalFrameDefault + 26124
56 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
57 libpython3.10.dylib 0x0000000101182430 PyVectorcall_Call + 144
58 libpython3.10.dylib 0x00000001012624a4 _PyEval_EvalFrameDefault + 26124
59 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
60 libpython3.10.dylib 0x0000000101264b9c call_function + 316
61 libpython3.10.dylib 0x0000000101262204 _PyEval_EvalFrameDefault + 25452
62 libpython3.10.dylib 0x000000010125bd8c _PyEval_Vector + 164
63 libpython3.10.dylib 0x0000000101264b9c call_function + 316
*** end of backtrace ***

One possible solution would be to upgrade the requests library to the latest version, which might resolve the issue if it is due to a bug in the library. You could also try to configure the requests library to use a specific proxy, rather than relying on the system's proxy settings, which may bypass the issue with the SystemConfiguration library.
Additionally, you could try to isolate the issue by disabling the uwsgi configuration option master = true and run the application with a single worker process. This would help you to determine if the problem is with uwsgi or with the requests library.

Related

Sum and Difference between numbers [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
Is it possible to find two numbers a and b such that difference between a and b is equal to sum of the digits in a and b ?
Is it possible to write a general equation for this?
Yes it is possible. A general code solution / algorithm for finding it would look like this. A mathematical solution would be be found by asking on https://math.stackexchange.com/
The below code checks all integer values between 1 and 10 for a and b
let a,b;
const maxIter = 10
let solution = []
for (a = 1;a < maxIter; a++) {
for (b = 1;b < maxIter; b++) {
const digitsInAB = `${a}${b}`.length
if (a-b === digitsInAB || b-a === digitsInAB)
solution.push({a,b})
}
}
console.log(solution)
Is it possible to find two numbers a and b such that the difference between a and b is equal to sum of the digits in a and b ? Is it possible to write a general equation for this?
Ruby:
def digits(n)
ans = 0
while n > 0 do
ans += n % 10
n /= 10
end
return ans
end
Now we just check the possibilities exhaustively, but assuming a <= b, and noting that b can't be much bigger than a. It can be at most one digit bigger than a, so you can check from a + d(a) + 1 up to a + d(a) + 9 * (1+count of digits in a).
Here we have the first few: a + digits(a) + digits(b) = b.
0 + 0 + 0 = 0
0 + 0 + 1 = 1
0 + 0 + 2 = 2
0 + 0 + 3 = 3
0 + 0 + 4 = 4
0 + 0 + 5 = 5
0 + 0 + 6 = 6
0 + 0 + 7 = 7
0 + 0 + 8 = 8
0 + 0 + 9 = 9
9 + 9 + 2 = 20
9 + 9 + 3 = 21
9 + 9 + 4 = 22
9 + 9 + 5 = 23
9 + 9 + 6 = 24
9 + 9 + 7 = 25
9 + 9 + 8 = 26
9 + 9 + 9 = 27
9 + 9 + 10 = 28
9 + 9 + 11 = 29
18 + 9 + 3 = 30
18 + 9 + 4 = 31
18 + 9 + 5 = 32
18 + 9 + 6 = 33
18 + 9 + 7 = 34
18 + 9 + 8 = 35
18 + 9 + 9 = 36
18 + 9 + 10 = 37
18 + 9 + 11 = 38
18 + 9 + 12 = 39
27 + 9 + 4 = 40
27 + 9 + 5 = 41
27 + 9 + 6 = 42
27 + 9 + 7 = 43
27 + 9 + 8 = 44
27 + 9 + 9 = 45
27 + 9 + 10 = 46
27 + 9 + 11 = 47
27 + 9 + 12 = 48
27 + 9 + 13 = 49
36 + 9 + 5 = 50
36 + 9 + 6 = 51
36 + 9 + 7 = 52
36 + 9 + 8 = 53
36 + 9 + 9 = 54
36 + 9 + 10 = 55
36 + 9 + 11 = 56
36 + 9 + 12 = 57
36 + 9 + 13 = 58
36 + 9 + 14 = 59
45 + 9 + 6 = 60
45 + 9 + 7 = 61
45 + 9 + 8 = 62
45 + 9 + 9 = 63
45 + 9 + 10 = 64
45 + 9 + 11 = 65
45 + 9 + 12 = 66
45 + 9 + 13 = 67
45 + 9 + 14 = 68
45 + 9 + 15 = 69
54 + 9 + 7 = 70
54 + 9 + 8 = 71
54 + 9 + 9 = 72
54 + 9 + 10 = 73
54 + 9 + 11 = 74
54 + 9 + 12 = 75
54 + 9 + 13 = 76
54 + 9 + 14 = 77
54 + 9 + 15 = 78
54 + 9 + 16 = 79
63 + 9 + 8 = 80
63 + 9 + 9 = 81
63 + 9 + 10 = 82
63 + 9 + 11 = 83
63 + 9 + 12 = 84
63 + 9 + 13 = 85
63 + 9 + 14 = 86
63 + 9 + 15 = 87
63 + 9 + 16 = 88
63 + 9 + 17 = 89
72 + 9 + 9 = 90
72 + 9 + 10 = 91
72 + 9 + 11 = 92
72 + 9 + 12 = 93
72 + 9 + 13 = 94
72 + 9 + 14 = 95
72 + 9 + 15 = 96
72 + 9 + 16 = 97
72 + 9 + 17 = 98
72 + 9 + 18 = 99
90 + 9 + 1 = 100
90 + 9 + 2 = 101
90 + 9 + 3 = 102
90 + 9 + 4 = 103
90 + 9 + 5 = 104
90 + 9 + 6 = 105
90 + 9 + 7 = 106
90 + 9 + 8 = 107
90 + 9 + 9 = 108
90 + 9 + 10 = 109
99 + 18 + 3 = 120
99 + 18 + 4 = 121
99 + 18 + 5 = 122
99 + 18 + 6 = 123
99 + 18 + 7 = 124
99 + 18 + 8 = 125
99 + 18 + 9 = 126
99 + 18 + 10 = 127
99 + 18 + 11 = 128
99 + 18 + 12 = 129
108 + 9 + 3 = 120
108 + 9 + 4 = 121
108 + 9 + 5 = 122
108 + 9 + 6 = 123
108 + 9 + 7 = 124
108 + 9 + 8 = 125
108 + 9 + 9 = 126
108 + 9 + 10 = 127
108 + 9 + 11 = 128
108 + 9 + 12 = 129
117 + 9 + 4 = 130
117 + 9 + 5 = 131
117 + 9 + 6 = 132
117 + 9 + 7 = 133
117 + 9 + 8 = 134
117 + 9 + 9 = 135
117 + 9 + 10 = 136
117 + 9 + 11 = 137
117 + 9 + 12 = 138
117 + 9 + 13 = 139
126 + 9 + 5 = 140
126 + 9 + 6 = 141
126 + 9 + 7 = 142
126 + 9 + 8 = 143
126 + 9 + 9 = 144
126 + 9 + 10 = 145
126 + 9 + 11 = 146
126 + 9 + 12 = 147
126 + 9 + 13 = 148
126 + 9 + 14 = 149
135 + 9 + 6 = 150
135 + 9 + 7 = 151
135 + 9 + 8 = 152
135 + 9 + 9 = 153
135 + 9 + 10 = 154
135 + 9 + 11 = 155
135 + 9 + 12 = 156
135 + 9 + 13 = 157
135 + 9 + 14 = 158
135 + 9 + 15 = 159
144 + 9 + 7 = 160
144 + 9 + 8 = 161
144 + 9 + 9 = 162
144 + 9 + 10 = 163
144 + 9 + 11 = 164
144 + 9 + 12 = 165
144 + 9 + 13 = 166
144 + 9 + 14 = 167
144 + 9 + 15 = 168
144 + 9 + 16 = 169
153 + 9 + 8 = 170
153 + 9 + 9 = 171
153 + 9 + 10 = 172
153 + 9 + 11 = 173
153 + 9 + 12 = 174
153 + 9 + 13 = 175
153 + 9 + 14 = 176
153 + 9 + 15 = 177
153 + 9 + 16 = 178
153 + 9 + 17 = 179
162 + 9 + 9 = 180
162 + 9 + 10 = 181
162 + 9 + 11 = 182
162 + 9 + 12 = 183
162 + 9 + 13 = 184
162 + 9 + 14 = 185
162 + 9 + 15 = 186
162 + 9 + 16 = 187
162 + 9 + 17 = 188
162 + 9 + 18 = 189
171 + 9 + 10 = 190
171 + 9 + 11 = 191
171 + 9 + 12 = 192
171 + 9 + 13 = 193
171 + 9 + 14 = 194
171 + 9 + 15 = 195
171 + 9 + 16 = 196
171 + 9 + 17 = 197
171 + 9 + 18 = 198
171 + 9 + 19 = 199
189 + 18 + 3 = 210
189 + 18 + 4 = 211
189 + 18 + 5 = 212
189 + 18 + 6 = 213
189 + 18 + 7 = 214
189 + 18 + 8 = 215
189 + 18 + 9 = 216
189 + 18 + 10 = 217
189 + 18 + 11 = 218
189 + 18 + 12 = 219
198 + 18 + 4 = 220
198 + 18 + 5 = 221
198 + 18 + 6 = 222
198 + 18 + 7 = 223
198 + 18 + 8 = 224
198 + 18 + 9 = 225
198 + 18 + 10 = 226
198 + 18 + 11 = 227
198 + 18 + 12 = 228
198 + 18 + 13 = 229
207 + 9 + 4 = 220
207 + 9 + 5 = 221
207 + 9 + 6 = 222
207 + 9 + 7 = 223
207 + 9 + 8 = 224
207 + 9 + 9 = 225
207 + 9 + 10 = 226
207 + 9 + 11 = 227
207 + 9 + 12 = 228
207 + 9 + 13 = 229
216 + 9 + 5 = 230
216 + 9 + 6 = 231
216 + 9 + 7 = 232
216 + 9 + 8 = 233
216 + 9 + 9 = 234
216 + 9 + 10 = 235
216 + 9 + 11 = 236
216 + 9 + 12 = 237
216 + 9 + 13 = 238
216 + 9 + 14 = 239
225 + 9 + 6 = 240
225 + 9 + 7 = 241
225 + 9 + 8 = 242
225 + 9 + 9 = 243
225 + 9 + 10 = 244
225 + 9 + 11 = 245
225 + 9 + 12 = 246
225 + 9 + 13 = 247
225 + 9 + 14 = 248
225 + 9 + 15 = 249
234 + 9 + 7 = 250
234 + 9 + 8 = 251
234 + 9 + 9 = 252
234 + 9 + 10 = 253
234 + 9 + 11 = 254
234 + 9 + 12 = 255
234 + 9 + 13 = 256
234 + 9 + 14 = 257
234 + 9 + 15 = 258
234 + 9 + 16 = 259
243 + 9 + 8 = 260
243 + 9 + 9 = 261
243 + 9 + 10 = 262
243 + 9 + 11 = 263
243 + 9 + 12 = 264
243 + 9 + 13 = 265
243 + 9 + 14 = 266
243 + 9 + 15 = 267
243 + 9 + 16 = 268
243 + 9 + 17 = 269
252 + 9 + 9 = 270
252 + 9 + 10 = 271
252 + 9 + 11 = 272
252 + 9 + 12 = 273
252 + 9 + 13 = 274
252 + 9 + 14 = 275
252 + 9 + 15 = 276
252 + 9 + 16 = 277
252 + 9 + 17 = 278
252 + 9 + 18 = 279
261 + 9 + 10 = 280
261 + 9 + 11 = 281
261 + 9 + 12 = 282
261 + 9 + 13 = 283
261 + 9 + 14 = 284
261 + 9 + 15 = 285
261 + 9 + 16 = 286
261 + 9 + 17 = 287
261 + 9 + 18 = 288
261 + 9 + 19 = 289
270 + 9 + 11 = 290
270 + 9 + 12 = 291
270 + 9 + 13 = 292
270 + 9 + 14 = 293
270 + 9 + 15 = 294
270 + 9 + 16 = 295
270 + 9 + 17 = 296
270 + 9 + 18 = 297
270 + 9 + 19 = 298
270 + 9 + 20 = 299
279 + 18 + 3 = 300
279 + 18 + 4 = 301
279 + 18 + 5 = 302
279 + 18 + 6 = 303
279 + 18 + 7 = 304
279 + 18 + 8 = 305
279 + 18 + 9 = 306
279 + 18 + 10 = 307
279 + 18 + 11 = 308
279 + 18 + 12 = 309
288 + 18 + 4 = 310
288 + 18 + 5 = 311
288 + 18 + 6 = 312
288 + 18 + 7 = 313
288 + 18 + 8 = 314
288 + 18 + 9 = 315
288 + 18 + 10 = 316
288 + 18 + 11 = 317
288 + 18 + 12 = 318
288 + 18 + 13 = 319
297 + 18 + 5 = 320
297 + 18 + 6 = 321
297 + 18 + 7 = 322
297 + 18 + 8 = 323
297 + 18 + 9 = 324
297 + 18 + 10 = 325
297 + 18 + 11 = 326
297 + 18 + 12 = 327
297 + 18 + 13 = 328
297 + 18 + 14 = 329
306 + 9 + 5 = 320
306 + 9 + 6 = 321
306 + 9 + 7 = 322
306 + 9 + 8 = 323
306 + 9 + 9 = 324
306 + 9 + 10 = 325
306 + 9 + 11 = 326
306 + 9 + 12 = 327
306 + 9 + 13 = 328
306 + 9 + 14 = 329
315 + 9 + 6 = 330
315 + 9 + 7 = 331
315 + 9 + 8 = 332
315 + 9 + 9 = 333
315 + 9 + 10 = 334
315 + 9 + 11 = 335
315 + 9 + 12 = 336
315 + 9 + 13 = 337
315 + 9 + 14 = 338
315 + 9 + 15 = 339
324 + 9 + 7 = 340
324 + 9 + 8 = 341
324 + 9 + 9 = 342
324 + 9 + 10 = 343
324 + 9 + 11 = 344
324 + 9 + 12 = 345
324 + 9 + 13 = 346
324 + 9 + 14 = 347
324 + 9 + 15 = 348
324 + 9 + 16 = 349
333 + 9 + 8 = 350
333 + 9 + 9 = 351
333 + 9 + 10 = 352
333 + 9 + 11 = 353
333 + 9 + 12 = 354
333 + 9 + 13 = 355
333 + 9 + 14 = 356
333 + 9 + 15 = 357
333 + 9 + 16 = 358
333 + 9 + 17 = 359
342 + 9 + 9 = 360
342 + 9 + 10 = 361
342 + 9 + 11 = 362
342 + 9 + 12 = 363
342 + 9 + 13 = 364
342 + 9 + 14 = 365
342 + 9 + 15 = 366
342 + 9 + 16 = 367
342 + 9 + 17 = 368
342 + 9 + 18 = 369
351 + 9 + 10 = 370
351 + 9 + 11 = 371
351 + 9 + 12 = 372
351 + 9 + 13 = 373
351 + 9 + 14 = 374
351 + 9 + 15 = 375
351 + 9 + 16 = 376
351 + 9 + 17 = 377
351 + 9 + 18 = 378
351 + 9 + 19 = 379
360 + 9 + 11 = 380
360 + 9 + 12 = 381
360 + 9 + 13 = 382
360 + 9 + 14 = 383
360 + 9 + 15 = 384
360 + 9 + 16 = 385
360 + 9 + 17 = 386
360 + 9 + 18 = 387
360 + 9 + 19 = 388
360 + 9 + 20 = 389
378 + 18 + 4 = 400
378 + 18 + 5 = 401
378 + 18 + 6 = 402
378 + 18 + 7 = 403
378 + 18 + 8 = 404
378 + 18 + 9 = 405
378 + 18 + 10 = 406
378 + 18 + 11 = 407
378 + 18 + 12 = 408
378 + 18 + 13 = 409
387 + 18 + 5 = 410
387 + 18 + 6 = 411
387 + 18 + 7 = 412
387 + 18 + 8 = 413
387 + 18 + 9 = 414
387 + 18 + 10 = 415
387 + 18 + 11 = 416
387 + 18 + 12 = 417
387 + 18 + 13 = 418
387 + 18 + 14 = 419
396 + 18 + 6 = 420
396 + 18 + 7 = 421
396 + 18 + 8 = 422
396 + 18 + 9 = 423
396 + 18 + 10 = 424
396 + 18 + 11 = 425
396 + 18 + 12 = 426
396 + 18 + 13 = 427
396 + 18 + 14 = 428
396 + 18 + 15 = 429
405 + 9 + 6 = 420
405 + 9 + 7 = 421
405 + 9 + 8 = 422
405 + 9 + 9 = 423
405 + 9 + 10 = 424
405 + 9 + 11 = 425
405 + 9 + 12 = 426
405 + 9 + 13 = 427
405 + 9 + 14 = 428
405 + 9 + 15 = 429
414 + 9 + 7 = 430
414 + 9 + 8 = 431
414 + 9 + 9 = 432
414 + 9 + 10 = 433
414 + 9 + 11 = 434
414 + 9 + 12 = 435
414 + 9 + 13 = 436
414 + 9 + 14 = 437
414 + 9 + 15 = 438
414 + 9 + 16 = 439
423 + 9 + 8 = 440
423 + 9 + 9 = 441
423 + 9 + 10 = 442
423 + 9 + 11 = 443
423 + 9 + 12 = 444
423 + 9 + 13 = 445
423 + 9 + 14 = 446
423 + 9 + 15 = 447
423 + 9 + 16 = 448
423 + 9 + 17 = 449
432 + 9 + 9 = 450
432 + 9 + 10 = 451
432 + 9 + 11 = 452
432 + 9 + 12 = 453
432 + 9 + 13 = 454
432 + 9 + 14 = 455
432 + 9 + 15 = 456
432 + 9 + 16 = 457
432 + 9 + 17 = 458
432 + 9 + 18 = 459
441 + 9 + 10 = 460
441 + 9 + 11 = 461
441 + 9 + 12 = 462
441 + 9 + 13 = 463
441 + 9 + 14 = 464
441 + 9 + 15 = 465
441 + 9 + 16 = 466
441 + 9 + 17 = 467
441 + 9 + 18 = 468
441 + 9 + 19 = 469
450 + 9 + 11 = 470
450 + 9 + 12 = 471
450 + 9 + 13 = 472
450 + 9 + 14 = 473
450 + 9 + 15 = 474
450 + 9 + 16 = 475
450 + 9 + 17 = 476
450 + 9 + 18 = 477
450 + 9 + 19 = 478
450 + 9 + 20 = 479
459 + 18 + 13 = 490
459 + 18 + 14 = 491
459 + 18 + 15 = 492
459 + 18 + 16 = 493
459 + 18 + 17 = 494
459 + 18 + 18 = 495
459 + 18 + 19 = 496
459 + 18 + 20 = 497
459 + 18 + 21 = 498
459 + 18 + 22 = 499
477 + 18 + 5 = 500
477 + 18 + 6 = 501
477 + 18 + 7 = 502
477 + 18 + 8 = 503
477 + 18 + 9 = 504
477 + 18 + 10 = 505
477 + 18 + 11 = 506
477 + 18 + 12 = 507
477 + 18 + 13 = 508
477 + 18 + 14 = 509
486 + 18 + 6 = 510
486 + 18 + 7 = 511
486 + 18 + 8 = 512
486 + 18 + 9 = 513
486 + 18 + 10 = 514
486 + 18 + 11 = 515
486 + 18 + 12 = 516
486 + 18 + 13 = 517
486 + 18 + 14 = 518
486 + 18 + 15 = 519
495 + 18 + 7 = 520
495 + 18 + 8 = 521
495 + 18 + 9 = 522
495 + 18 + 10 = 523
495 + 18 + 11 = 524
495 + 18 + 12 = 525
495 + 18 + 13 = 526
495 + 18 + 14 = 527
495 + 18 + 15 = 528
495 + 18 + 16 = 529
504 + 9 + 7 = 520
504 + 9 + 8 = 521
504 + 9 + 9 = 522
504 + 9 + 10 = 523
504 + 9 + 11 = 524
504 + 9 + 12 = 525
504 + 9 + 13 = 526
504 + 9 + 14 = 527
504 + 9 + 15 = 528
504 + 9 + 16 = 529
513 + 9 + 8 = 530
513 + 9 + 9 = 531
513 + 9 + 10 = 532
513 + 9 + 11 = 533
513 + 9 + 12 = 534
513 + 9 + 13 = 535
513 + 9 + 14 = 536
513 + 9 + 15 = 537
513 + 9 + 16 = 538
513 + 9 + 17 = 539
522 + 9 + 9 = 540
522 + 9 + 10 = 541
522 + 9 + 11 = 542
522 + 9 + 12 = 543
522 + 9 + 13 = 544
522 + 9 + 14 = 545
522 + 9 + 15 = 546
522 + 9 + 16 = 547
522 + 9 + 17 = 548
522 + 9 + 18 = 549
531 + 9 + 10 = 550
531 + 9 + 11 = 551
531 + 9 + 12 = 552
531 + 9 + 13 = 553
531 + 9 + 14 = 554
531 + 9 + 15 = 555
531 + 9 + 16 = 556
531 + 9 + 17 = 557
531 + 9 + 18 = 558
531 + 9 + 19 = 559
540 + 9 + 11 = 560
540 + 9 + 12 = 561
540 + 9 + 13 = 562
540 + 9 + 14 = 563
540 + 9 + 15 = 564
540 + 9 + 16 = 565
540 + 9 + 17 = 566
540 + 9 + 18 = 567
540 + 9 + 19 = 568
540 + 9 + 20 = 569
549 + 18 + 13 = 580
549 + 18 + 14 = 581
549 + 18 + 15 = 582
549 + 18 + 16 = 583
549 + 18 + 17 = 584
549 + 18 + 18 = 585
549 + 18 + 19 = 586
549 + 18 + 20 = 587
549 + 18 + 21 = 588
549 + 18 + 22 = 589
558 + 18 + 14 = 590
558 + 18 + 15 = 591
558 + 18 + 16 = 592
558 + 18 + 17 = 593
558 + 18 + 18 = 594
558 + 18 + 19 = 595
558 + 18 + 20 = 596
558 + 18 + 21 = 597
558 + 18 + 22 = 598
558 + 18 + 23 = 599
576 + 18 + 6 = 600
576 + 18 + 7 = 601
576 + 18 + 8 = 602
576 + 18 + 9 = 603
576 + 18 + 10 = 604
576 + 18 + 11 = 605
576 + 18 + 12 = 606
576 + 18 + 13 = 607
576 + 18 + 14 = 608
576 + 18 + 15 = 609
585 + 18 + 7 = 610
585 + 18 + 8 = 611
585 + 18 + 9 = 612
585 + 18 + 10 = 613
585 + 18 + 11 = 614
585 + 18 + 12 = 615
585 + 18 + 13 = 616
585 + 18 + 14 = 617
585 + 18 + 15 = 618
585 + 18 + 16 = 619
594 + 18 + 8 = 620
594 + 18 + 9 = 621
594 + 18 + 10 = 622
594 + 18 + 11 = 623
594 + 18 + 12 = 624
594 + 18 + 13 = 625
594 + 18 + 14 = 626
594 + 18 + 15 = 627
594 + 18 + 16 = 628
594 + 18 + 17 = 629
603 + 9 + 8 = 620
603 + 9 + 9 = 621
603 + 9 + 10 = 622
603 + 9 + 11 = 623
603 + 9 + 12 = 624
603 + 9 + 13 = 625
603 + 9 + 14 = 626
603 + 9 + 15 = 627
603 + 9 + 16 = 628
603 + 9 + 17 = 629
612 + 9 + 9 = 630
612 + 9 + 10 = 631
612 + 9 + 11 = 632
612 + 9 + 12 = 633
612 + 9 + 13 = 634
612 + 9 + 14 = 635
612 + 9 + 15 = 636
612 + 9 + 16 = 637
612 + 9 + 17 = 638
612 + 9 + 18 = 639
621 + 9 + 10 = 640
621 + 9 + 11 = 641
621 + 9 + 12 = 642
621 + 9 + 13 = 643
621 + 9 + 14 = 644
621 + 9 + 15 = 645
621 + 9 + 16 = 646
621 + 9 + 17 = 647
621 + 9 + 18 = 648
621 + 9 + 19 = 649
630 + 9 + 11 = 650
630 + 9 + 12 = 651
630 + 9 + 13 = 652
630 + 9 + 14 = 653
630 + 9 + 15 = 654
630 + 9 + 16 = 655
630 + 9 + 17 = 656
630 + 9 + 18 = 657
630 + 9 + 19 = 658
630 + 9 + 20 = 659
639 + 18 + 13 = 670
639 + 18 + 14 = 671
639 + 18 + 15 = 672
639 + 18 + 16 = 673
639 + 18 + 17 = 674
639 + 18 + 18 = 675
639 + 18 + 19 = 676
639 + 18 + 20 = 677
639 + 18 + 21 = 678
639 + 18 + 22 = 679
648 + 18 + 14 = 680
648 + 18 + 15 = 681
648 + 18 + 16 = 682
648 + 18 + 17 = 683
648 + 18 + 18 = 684
648 + 18 + 19 = 685
648 + 18 + 20 = 686
648 + 18 + 21 = 687
648 + 18 + 22 = 688
648 + 18 + 23 = 689
657 + 18 + 15 = 690
657 + 18 + 16 = 691
657 + 18 + 17 = 692
657 + 18 + 18 = 693
657 + 18 + 19 = 694
657 + 18 + 20 = 695
657 + 18 + 21 = 696
657 + 18 + 22 = 697
657 + 18 + 23 = 698
657 + 18 + 24 = 699
675 + 18 + 7 = 700
675 + 18 + 8 = 701
675 + 18 + 9 = 702
675 + 18 + 10 = 703
675 + 18 + 11 = 704
675 + 18 + 12 = 705
675 + 18 + 13 = 706
675 + 18 + 14 = 707
675 + 18 + 15 = 708
675 + 18 + 16 = 709
684 + 18 + 8 = 710
684 + 18 + 9 = 711
684 + 18 + 10 = 712
684 + 18 + 11 = 713
684 + 18 + 12 = 714
684 + 18 + 13 = 715
684 + 18 + 14 = 716
684 + 18 + 15 = 717
684 + 18 + 16 = 718
684 + 18 + 17 = 719
693 + 18 + 9 = 720
693 + 18 + 10 = 721
693 + 18 + 11 = 722
693 + 18 + 12 = 723
693 + 18 + 13 = 724
693 + 18 + 14 = 725
693 + 18 + 15 = 726
693 + 18 + 16 = 727
693 + 18 + 17 = 728
693 + 18 + 18 = 729
702 + 9 + 9 = 720
702 + 9 + 10 = 721
702 + 9 + 11 = 722
702 + 9 + 12 = 723
702 + 9 + 13 = 724
702 + 9 + 14 = 725
702 + 9 + 15 = 726
702 + 9 + 16 = 727
702 + 9 + 17 = 728
702 + 9 + 18 = 729
711 + 9 + 10 = 730
711 + 9 + 11 = 731
711 + 9 + 12 = 732
711 + 9 + 13 = 733
711 + 9 + 14 = 734
711 + 9 + 15 = 735
711 + 9 + 16 = 736
711 + 9 + 17 = 737
711 + 9 + 18 = 738
711 + 9 + 19 = 739
720 + 9 + 11 = 740
720 + 9 + 12 = 741
720 + 9 + 13 = 742
720 + 9 + 14 = 743
720 + 9 + 15 = 744
720 + 9 + 16 = 745
720 + 9 + 17 = 746
720 + 9 + 18 = 747
720 + 9 + 19 = 748
720 + 9 + 20 = 749
729 + 18 + 13 = 760
729 + 18 + 14 = 761
729 + 18 + 15 = 762
729 + 18 + 16 = 763
729 + 18 + 17 = 764
729 + 18 + 18 = 765
729 + 18 + 19 = 766
729 + 18 + 20 = 767
729 + 18 + 21 = 768
729 + 18 + 22 = 769
738 + 18 + 14 = 770
738 + 18 + 15 = 771
738 + 18 + 16 = 772
738 + 18 + 17 = 773
738 + 18 + 18 = 774
738 + 18 + 19 = 775
738 + 18 + 20 = 776
738 + 18 + 21 = 777
738 + 18 + 22 = 778
738 + 18 + 23 = 779
747 + 18 + 15 = 780
747 + 18 + 16 = 781
747 + 18 + 17 = 782
747 + 18 + 18 = 783
747 + 18 + 19 = 784
747 + 18 + 20 = 785
747 + 18 + 21 = 786
747 + 18 + 22 = 787
747 + 18 + 23 = 788
747 + 18 + 24 = 789
756 + 18 + 16 = 790
756 + 18 + 17 = 791
756 + 18 + 18 = 792
756 + 18 + 19 = 793
756 + 18 + 20 = 794
756 + 18 + 21 = 795
756 + 18 + 22 = 796
756 + 18 + 23 = 797
756 + 18 + 24 = 798
756 + 18 + 25 = 799
774 + 18 + 8 = 800
774 + 18 + 9 = 801
774 + 18 + 10 = 802
774 + 18 + 11 = 803
774 + 18 + 12 = 804
774 + 18 + 13 = 805
774 + 18 + 14 = 806
774 + 18 + 15 = 807
774 + 18 + 16 = 808
774 + 18 + 17 = 809
783 + 18 + 9 = 810
783 + 18 + 10 = 811
783 + 18 + 11 = 812
783 + 18 + 12 = 813
783 + 18 + 13 = 814
783 + 18 + 14 = 815
783 + 18 + 15 = 816
783 + 18 + 16 = 817
783 + 18 + 17 = 818
783 + 18 + 18 = 819
792 + 18 + 10 = 820
792 + 18 + 11 = 821
792 + 18 + 12 = 822
792 + 18 + 13 = 823
792 + 18 + 14 = 824
792 + 18 + 15 = 825
792 + 18 + 16 = 826
792 + 18 + 17 = 827
792 + 18 + 18 = 828
792 + 18 + 19 = 829
801 + 9 + 10 = 820
801 + 9 + 11 = 821
801 + 9 + 12 = 822
801 + 9 + 13 = 823
801 + 9 + 14 = 824
801 + 9 + 15 = 825
801 + 9 + 16 = 826
801 + 9 + 17 = 827
801 + 9 + 18 = 828
801 + 9 + 19 = 829
810 + 9 + 11 = 830
810 + 9 + 12 = 831
810 + 9 + 13 = 832
810 + 9 + 14 = 833
810 + 9 + 15 = 834
810 + 9 + 16 = 835
810 + 9 + 17 = 836
810 + 9 + 18 = 837
810 + 9 + 19 = 838
810 + 9 + 20 = 839
819 + 18 + 13 = 850
819 + 18 + 14 = 851
819 + 18 + 15 = 852
819 + 18 + 16 = 853
819 + 18 + 17 = 854
819 + 18 + 18 = 855
819 + 18 + 19 = 856
819 + 18 + 20 = 857
819 + 18 + 21 = 858
819 + 18 + 22 = 859
828 + 18 + 14 = 860
828 + 18 + 15 = 861
828 + 18 + 16 = 862
828 + 18 + 17 = 863
828 + 18 + 18 = 864
828 + 18 + 19 = 865
828 + 18 + 20 = 866
828 + 18 + 21 = 867
828 + 18 + 22 = 868
828 + 18 + 23 = 869
837 + 18 + 15 = 870
837 + 18 + 16 = 871
837 + 18 + 17 = 872
837 + 18 + 18 = 873
837 + 18 + 19 = 874
837 + 18 + 20 = 875
837 + 18 + 21 = 876
837 + 18 + 22 = 877
837 + 18 + 23 = 878
837 + 18 + 24 = 879
846 + 18 + 16 = 880
846 + 18 + 17 = 881
846 + 18 + 18 = 882
846 + 18 + 19 = 883
846 + 18 + 20 = 884
846 + 18 + 21 = 885
846 + 18 + 22 = 886
846 + 18 + 23 = 887
846 + 18 + 24 = 888
846 + 18 + 25 = 889
855 + 18 + 17 = 890
855 + 18 + 18 = 891
855 + 18 + 19 = 892
855 + 18 + 20 = 893
855 + 18 + 21 = 894
855 + 18 + 22 = 895
855 + 18 + 23 = 896
855 + 18 + 24 = 897
855 + 18 + 25 = 898
855 + 18 + 26 = 899
873 + 18 + 9 = 900
873 + 18 + 10 = 901
873 + 18 + 11 = 902
873 + 18 + 12 = 903
873 + 18 + 13 = 904
873 + 18 + 14 = 905
873 + 18 + 15 = 906
873 + 18 + 16 = 907
873 + 18 + 17 = 908
873 + 18 + 18 = 909
882 + 18 + 10 = 910
882 + 18 + 11 = 911
882 + 18 + 12 = 912
882 + 18 + 13 = 913
882 + 18 + 14 = 914
882 + 18 + 15 = 915
882 + 18 + 16 = 916
882 + 18 + 17 = 917
882 + 18 + 18 = 918
882 + 18 + 19 = 919
891 + 18 + 11 = 920
891 + 18 + 12 = 921
891 + 18 + 13 = 922
891 + 18 + 14 = 923
891 + 18 + 15 = 924
891 + 18 + 16 = 925
891 + 18 + 17 = 926
891 + 18 + 18 = 927
891 + 18 + 19 = 928
891 + 18 + 20 = 929
900 + 9 + 11 = 920
900 + 9 + 12 = 921
900 + 9 + 13 = 922
900 + 9 + 14 = 923
900 + 9 + 15 = 924
900 + 9 + 16 = 925
900 + 9 + 17 = 926
900 + 9 + 18 = 927
900 + 9 + 19 = 928
900 + 9 + 20 = 929
909 + 18 + 13 = 940
909 + 18 + 14 = 941
909 + 18 + 15 = 942
909 + 18 + 16 = 943
909 + 18 + 17 = 944
909 + 18 + 18 = 945
909 + 18 + 19 = 946
909 + 18 + 20 = 947
909 + 18 + 21 = 948
909 + 18 + 22 = 949
918 + 18 + 14 = 950
918 + 18 + 15 = 951
918 + 18 + 16 = 952
918 + 18 + 17 = 953
918 + 18 + 18 = 954
918 + 18 + 19 = 955
918 + 18 + 20 = 956
927 + 18 + 16 = 961
927 + 18 + 17 = 962
927 + 18 + 18 = 963
927 + 18 + 19 = 964
927 + 18 + 20 = 965
927 + 18 + 21 = 966
927 + 18 + 22 = 967
927 + 18 + 23 = 968
927 + 18 + 24 = 969
936 + 18 + 16 = 970
936 + 18 + 17 = 971
936 + 18 + 18 = 972
936 + 18 + 19 = 973
936 + 18 + 20 = 974
936 + 18 + 21 = 975
936 + 18 + 22 = 976
936 + 18 + 23 = 977
936 + 18 + 24 = 978
936 + 18 + 25 = 979
945 + 18 + 17 = 980
945 + 18 + 18 = 981
945 + 18 + 19 = 982
945 + 18 + 20 = 983
945 + 18 + 21 = 984
945 + 18 + 22 = 985
945 + 18 + 23 = 986
945 + 18 + 24 = 987
945 + 18 + 25 = 988
945 + 18 + 26 = 989
954 + 18 + 18 = 990
954 + 18 + 19 = 991
954 + 18 + 20 = 992
954 + 18 + 21 = 993
954 + 18 + 22 = 994
954 + 18 + 23 = 995
954 + 18 + 24 = 996
954 + 18 + 25 = 997
954 + 18 + 26 = 998
954 + 18 + 27 = 999
981 + 18 + 1 = 1000
981 + 18 + 2 = 1001
981 + 18 + 3 = 1002
981 + 18 + 4 = 1003
981 + 18 + 5 = 1004
981 + 18 + 6 = 1005
981 + 18 + 7 = 1006
981 + 18 + 8 = 1007
981 + 18 + 9 = 1008
981 + 18 + 10 = 1009
990 + 18 + 2 = 1010
990 + 18 + 3 = 1011
990 + 18 + 4 = 1012
990 + 18 + 5 = 1013
990 + 18 + 6 = 1014
990 + 18 + 7 = 1015
990 + 18 + 8 = 1016
990 + 18 + 9 = 1017
990 + 18 + 10 = 1018
990 + 18 + 11 = 1019
999 + 27 + 4 = 1030
999 + 27 + 5 = 1031
999 + 27 + 6 = 1032
999 + 27 + 7 = 1033
999 + 27 + 8 = 1034
999 + 27 + 9 = 1035
999 + 27 + 10 = 1036
999 + 27 + 11 = 1037
999 + 27 + 12 = 1038
999 + 27 + 13 = 1039

Plot dots over dateline with ggplot in R

I'm trying to plot some dots on a map in R but only half of them show up. I suppose it might have something to do with the dateline.
My sample data:
sites
longitude latitude
1 -136 53
2 140 33
3 -176 59
4 -138 47
5 -170 61
6 142 35
7 -128 45
8 -178 55
9 -140 57
10 -168 39
11 158 39
12 -178 45
13 144 45
14 -166 25
15 162 47
16 -178 35
17 -178 43
18 146 39
19 138 25
20 -178 25
21 140 33
22 166 45
23 142 37
24 164 45
25 -162 39
26 156 39
27 -178 53
28 -178 29
29 -150 59
30 -178 35
31 -176 57
32 138 43
33 164 59
34 -152 37
35 152 39
36 -178 61
37 164 35
38 174 51
39 -176 29
40 154 41
41 -140 51
42 120 35
43 -178 53
44 -168 55
45 -172 65
46 -126 59
47 -178 53
48 -144 45
49 -178 37
50 -122 59
51 -178 27
52 -176 43
53 128 27
54 -130 33
55 134 37
56 -156 55
57 -176 41
58 148 47
59 146 37
60 -164 37
61 158 35
62 124 47
63 162 63
64 -178 47
65 144 37
66 -170 25
67 120 41
68 -164 41
69 -178 45
70 140 47
71 164 45
72 -164 39
73 -178 41
74 120 35
75 -150 41
76 -154 45
77 124 43
78 148 39
79 -162 43
80 152 35
81 -138 39
82 124 29
83 -168 51
84 146 49
85 -178 35
86 -152 49
87 -162 43
88 160 53
89 152 35
90 126 31
91 -156 47
92 -174 33
93 164 41
94 160 37
95 -154 25
96 -178 41
97 142 49
98 -178 35
99 -178 51
100 138 35
101 -120 41
102 -160 47
103 148 37
104 166 41
105 -148 37
106 146 37
107 -168 53
108 -178 37
109 132 29
110 -122 57
The code:
wrld2 = st_as_sf(map('world2', plot=F, fill=T))
ggplot() +
geom_sf(data=wrld2, fill='lightgrey') +
geom_point(data=sites, aes(x = longitude, y = latitude), size = 4,
shape = 22, fill = "darkblue") +
coord_sf(xlim=c(-180,-120), ylim=c(25,65)) +
geom_sf(data=wrld2, fill='lightgrey') +
geom_point() +
geom_point(data=sites, aes(x = longitude, y = latitude), size = 4,
shape = 21, fill = "darkred") +
coord_sf(xlim=c(120,240), ylim=c(25,65)) +
theme(panel.background = element_rect(fill = "aliceblue"))
Only the Western part of the dateline is plotted with the correct dots (others are put on top):
The problem is that the blue data points are not plotted in their specific range (-180,-120 and 25,65) because of the two coordinate systems/dateline around +/- 180°. I can't seem to figure how to define the correct xlim so that the longitude ticks remain the same on the x-axis. Has anyone an idea what is missing or needs to be re-defined? Many thanks.

Smoothed shaded region

I am trying to create a line graph with error regions (instead of error bars). This is my data:
data <- read.table(text = "
Water_mass Time Abundance Mean sd Upper Lower
1 FRONT 1 265 281.75000 54.524459 336.27446 227.22554
2 FRONT 1 359 281.75000 54.524459 336.27446 227.22554
3 FRONT 1 272 281.75000 54.524459 336.27446 227.22554
4 FRONT 1 231 281.75000 54.524459 336.27446 227.22554
5 FRONT 188 40 57.80000 19.227584 77.02758 38.57242
6 FRONT 188 57 57.80000 19.227584 77.02758 38.57242
7 FRONT 188 38 57.80000 19.227584 77.02758 38.57242
8 FRONT 188 73 57.80000 19.227584 77.02758 38.57242
9 FRONT 188 81 57.80000 19.227584 77.02758 38.57242
10 FRONT 353 131 346.25000 253.898109 600.14811 92.35189
11 FRONT 353 622 346.25000 253.898109 600.14811 92.35189
12 FRONT 353 502 346.25000 253.898109 600.14811 92.35189
13 FRONT 353 130 346.25000 253.898109 600.14811 92.35189
14 FRONT 434 38 47.50000 13.435029 60.93503 34.06497
15 FRONT 434 57 47.50000 13.435029 60.93503 34.06497
16 FRONT 476 52 49.50000 3.535534 53.03553 45.96447
17 FRONT 476 47 49.50000 3.535534 53.03553 45.96447
18 NW 1 232 232.00000 NA NA NA
19 NW 154 140 138.50000 2.121320 140.62132 136.37868
20 NW 154 137 138.50000 2.121320 140.62132 136.37868
21 NW 188 252 253.00000 1.414214 254.41421 251.58579
22 NW 188 254 253.00000 1.414214 254.41421 251.58579
23 NW 353 3846 1957.50000 2670.742313 4628.24231 -713.24231
24 NW 353 69 1957.50000 2670.742313 4628.24231 -713.24231
25 NW 434 162 181.75000 80.748065 262.49806 101.00194
26 NW 434 93 181.75000 80.748065 262.49806 101.00194
27 NW 434 184 181.75000 80.748065 262.49806 101.00194
28 NW 434 288 181.75000 80.748065 262.49806 101.00194
29 NW 476 149 181.00000 45.254834 226.25483 135.74517
30 NW 476 213 181.00000 45.254834 226.25483 135.74517
31 SAW 1 143 147.16667 13.717386 160.88405 133.44928
32 SAW 1 137 147.16667 13.717386 160.88405 133.44928
33 SAW 1 170 147.16667 13.717386 160.88405 133.44928
34 SAW 1 149 147.16667 13.717386 160.88405 133.44928
35 SAW 1 153 147.16667 13.717386 160.88405 133.44928
36 SAW 1 131 147.16667 13.717386 160.88405 133.44928
37 SAW 154 79 61.66667 11.269428 72.93609 50.39724
38 SAW 154 65 61.66667 11.269428 72.93609 50.39724
39 SAW 154 52 61.66667 11.269428 72.93609 50.39724
40 SAW 154 48 61.66667 11.269428 72.93609 50.39724
41 SAW 154 74 61.66667 11.269428 72.93609 50.39724
42 SAW 154 52 61.66667 11.269428 72.93609 50.39724
43 SAW 154 51 61.66667 11.269428 72.93609 50.39724
44 SAW 154 69 61.66667 11.269428 72.93609 50.39724
45 SAW 154 65 61.66667 11.269428 72.93609 50.39724
46 SAW 188 68 55.50000 9.327379 64.82738 46.17262
47 SAW 188 47 55.50000 9.327379 64.82738 46.17262
48 SAW 188 57 55.50000 9.327379 64.82738 46.17262
49 SAW 188 50 55.50000 9.327379 64.82738 46.17262
50 SAW 353 868 696.60000 229.660184 926.26018 466.93982
51 SAW 353 728 696.60000 229.660184 926.26018 466.93982
52 SAW 353 354 696.60000 229.660184 926.26018 466.93982
53 SAW 353 930 696.60000 229.660184 926.26018 466.93982
54 SAW 353 603 696.60000 229.660184 926.26018 466.93982
55 SAW 434 31 31.57143 6.106203 37.67763 25.46523
56 SAW 434 33 31.57143 6.106203 37.67763 25.46523
57 SAW 434 19 31.57143 6.106203 37.67763 25.46523
58 SAW 434 30 31.57143 6.106203 37.67763 25.46523
59 SAW 434 35 31.57143 6.106203 37.67763 25.46523
60 SAW 434 36 31.57143 6.106203 37.67763 25.46523
61 SAW 434 37 31.57143 6.106203 37.67763 25.46523
62 SAW 476 96 60.75000 24.185050 84.93505 36.56495
63 SAW 476 54 60.75000 24.185050 84.93505 36.56495
64 SAW 476 41 60.75000 24.185050 84.93505 36.56495
65 SAW 476 52 60.75000 24.185050 84.93505 36.56495
66 STW 1 194 177.66667 20.256686 197.92335 157.40998
67 STW 1 184 177.66667 20.256686 197.92335 157.40998
68 STW 1 155 177.66667 20.256686 197.92335 157.40998
69 STW 154 44 49.66667 6.658328 56.32499 43.00834
70 STW 154 57 49.66667 6.658328 56.32499 43.00834
71 STW 154 48 49.66667 6.658328 56.32499 43.00834
72 STW 188 185 101.33333 72.500575 173.83391 28.83276
73 STW 188 57 101.33333 72.500575 173.83391 28.83276
74 STW 188 62 101.33333 72.500575 173.83391 28.83276
75 STW 353 2846 3367.66667 890.594371 4258.26104 2477.07230
76 STW 353 2861 3367.66667 890.594371 4258.26104 2477.07230
77 STW 353 4396 3367.66667 890.594371 4258.26104 2477.07230
78 STW 434 73 54.50000 26.162951 80.66295 28.33705
79 STW 434 36 54.50000 26.162951 80.66295 28.33705
80 STW 476 100 135.20000 31.523007 166.72301 103.67699
81 STW 476 115 135.20000 31.523007 166.72301 103.67699
82 STW 476 180 135.20000 31.523007 166.72301 103.67699
83 STW 476 129 135.20000 31.523007 166.72301 103.67699
84 STW 476 152 135.20000 31.523007 166.72301 103.67699
", header = TRUE)
Using this code, I am able to create a graph that is similar to what I want:
ggplot(data,aes(x=Time,y=Abundance,col=Water_mass))+ geom_point() + ylab("Abundance")+ xlab("Time (days)") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.border = element_rect(colour = "lightgray", fill=NA),
panel.background = element_blank())+
theme(strip.background = element_blank()) +
labs(colour="Water mass") +
geom_point(size=3) +
scale_y_continuous(limit=c(0,NA),oob=squish) +
geom_ribbon(aes(ymin = b$Lower, ymax = b$Upper, fill = b$Water_mass), data= b, alpha = 0.2, show.legend = FALSE, colour=NA)+
geom_line(aes(y=Mean, colour=Water_mass), data= b, size=1.5)
However, I would prefer it if the lines were smoothed. I was able to smooth the mean, but not the confidence regions:
ggplot(data,aes(x=Time,y=Abundance,col=Water_mass))+ geom_point() +
ylab("Abundance")+ xlab("Time (days)") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.border = element_rect(colour = "lightgray", fill=NA),
panel.background = element_blank())+
theme(strip.background = element_blank()) +
labs(colour="Water mass") +
geom_point(size=3) +
scale_y_continuous(limit=c(0,NA),oob=squish) +
geom_ribbon(aes(ymin = b$Lower, ymax = b$Upper, fill = b$Water_mass), data= b, alpha = 0.2, show.legend = FALSE, colour=NA)+
stat_smooth(se=F, size=1.5)
Is it possible to smooth the confidence regions too?
I have also tried this, which looks the way I want, except that it shows 95% confidence intervals for the mean, instead of some measure of spread of the data:
ggplot(data,aes(x=Time,y=Abundance,col=Water_mass))+ geom_point() + ylab("Abundance")+ xlab("Time (days)") +
theme_bw() +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.border = element_rect(colour = "lightgray", fill=NA),
panel.background = element_blank())+
theme(strip.background = element_blank()) +
labs(colour="Water mass") + geom_point(size=3) +
geom_smooth(method="auto", se=TRUE, fullrange=FALSE, level=0.95, aes(fill = Water_mass), show.legend = FALSE) +
scale_y_continuous(limit=c(0,NA),oob=squish)

SQL queries in R with RJDBC crash if column or table doesn't exist

After creating a simple connection conn to an Oracle database, I write a query like the below:
dbGetQuery(conn, "select * from CUSTOMERS where rownum <= 10")
Since the table CUSTOMERS exists, this returns a set of rows.
However, if I write the below query and accidentally type CSUTOMERS, (the U and S are switched), I get an error that actually CLOSES R or RStudio. I like to use R interactively, which means that I'll inevitably make typos and reference tables or columns that don't exist. RJDBC is completely unusable if it crashes your R session because you make a typo in SQL.
Below is the code and resultant error.
dbGetQuery(conn, "select * from CSUTOMERS where rownum <= 10")
2016-04-04 20:03:27.475 R[3292:355239] Apple AWT Internal Exception : java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:873)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1491)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
2016-04-04 20:03:27.475 R[3292:355239] *** Terminating app due to uncaught exception 'JavaNativeException', reason: 'java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff998c803c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff9065976e objc_exception_throw + 43
2 CoreFoundation 0x00007fff998c7bd9 -[NSException raise] + 9
3 JavaNativeFoundation 0x000000010cc4fc3f JNFCallStaticVoidMethod + 213
4 libawt.jnilib 0x00000001157a614d setBusy + 53
5 CoreFoundation 0x00007fff997e4127 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
6 CoreFoundation 0x00007fff997e4080 __CFRunLoopDoObservers + 368
7 CoreFoundation 0x00007fff997d62ba __CFRunLoopRun + 1178
8 CoreFoundation 0x00007fff997d5bd8 CFRunLoopRunSpecific + 296
9 libtcl8.6.dylib 0x000000010c10c6a7 Tcl_WaitForEvent + 293
10 libtcl8.6.dylib 0x000000010c0c2742 Tcl_DoOneEvent + 357
11 tcltk.so 0x000000010c01a6ca TclSpinLoop + 26
12 libR.dylib 0x0000000106700188 R_ToplevelExec + 456
13 tcltk.so 0x000000010c01a697 TclHandler + 55
14 libR.dylib 0x000000010689e277 R_ProcessEvents + 55
15 libR.dylib 0x000000010673f49d R_CheckUserInterrupt + 77
16 libR.dylib 0x0000000106745062 Rf_eval + 66
17 libR.dylib 0x0000000106735b9b Rf_findFun + 331
18 libR.dylib 0x000000010674cb93 bcEval + 29491
19 libR.dylib 0x00000001067451a6 Rf_eval + 390
20 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
21 libR.dylib 0x0000000106756999 bcEval + 69945
22 libR.dylib 0x00000001067451a6 Rf_eval + 390
23 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
24 libR.dylib 0x0000000106745537 Rf_eval + 1303
25 libR.dylib 0x000000010679ebe3 do_begin + 451
26 libR.dylib 0x000000010674562e Rf_eval + 1550
27 libR.dylib 0x000000010674562e Rf_eval + 1550
28 libR.dylib 0x000000010679ebe3 do_begin + 451
29 libR.dylib 0x000000010674562e Rf_eval + 1550
30 libR.dylib 0x000000010679cf2e R_execClosure + 926
31 libR.dylib 0x000000010679cb25 R_execMethod + 613
32 methods.so 0x00000001088946cd R_dispatchGeneric + 2173
33 libR.dylib 0x00000001067e1cda do_standardGeneric + 634
34 libR.dylib 0x0000000106757d4d bcEval + 74989
35 libR.dylib 0x00000001067451a6 Rf_eval + 390
36 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
37 libR.dylib 0x0000000106756999 bcEval + 69945
38 libR.dylib 0x00000001067451a6 Rf_eval + 390
39 libR.dylib 0x000000010679cf2e R_execClosure + 926
40 libR.dylib 0x000000010679cb25 R_execMethod + 613
41 methods.so 0x00000001088946cd R_dispatchGeneric + 2173
42 libR.dylib 0x00000001067e1cda do_standardGeneric + 634
43 libR.dylib 0x00000001067456a8 Rf_eval + 1672
44 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
45 libR.dylib 0x0000000106745537 Rf_eval + 1303
46 libR.dylib 0x000000010679f752 do_set + 1858
47 libR.dylib 0x000000010674562e Rf_eval + 1550
48 libR.dylib 0x000000010679ebe3 do_begin + 451
49 libR.dylib 0x000000010674562e Rf_eval + 1550
50 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
51 libR.dylib 0x0000000106745537 Rf_eval + 1303
52 libR.dylib 0x000000010679f752 do_set + 1858
53 libR.dylib 0x000000010674562e Rf_eval + 1550
54 libR.dylib 0x000000010679ebe3 do_begin + 451
55 libR.dylib 0x000000010674562e Rf_eval + 1550
56 libR.dylib 0x000000010674562e Rf_eval + 1550
57 libR.dylib 0x000000010679ebe3 do_begin + 451
58 libR.dylib 0x000000010674562e Rf_eval + 1550
59 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
60 libR.dylib 0x0000000106745537 Rf_eval + 1303
61 libR.dylib 0x000000010679ebe3 do_begin + 451
62 libR.dylib 0x000000010674562e Rf_eval + 1550
63 libR.dylib 0x000000010674562e Rf_eval + 1550
64 libR.dylib 0x000000010674562e Rf_eval + 1550
65 libR.dylib 0x000000010679ebe3 do_begin + 451
66 libR.dylib 0x000000010674562e Rf_eval + 1550
67 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
68 libR.dylib 0x0000000106745537 Rf_eval + 1303
69 libR.dylib 0x000000010679ebe3 do_begin + 451
70 libR.dylib 0x000000010674562e Rf_eval + 1550
71 libR.dylib 0x000000010679cf2e R_execClosure + 926
72 libR.dylib 0x000000010679cb25 R_execMethod + 613
73 methods.so 0x00000001088946cd R_dispatchGeneric + 2173
74 libR.dylib 0x00000001067e1cda do_standardGeneric + 634
75 libR.dylib 0x00000001067456a8 Rf_eval + 1672
76 libR.dylib 0x000000010679f752 do_set + 1858
77 libR.dylib 0x000000010674562e Rf_eval + 1550
78 libR.dylib 0x000000010679ebe3 do_begin + 451
79 libR.dylib 0x000000010674562e Rf_eval + 1550
80 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
81 libR.dylib 0x0000000106745537 Rf_eval + 1303
82 libR.dylib 0x000000010679f752 do_set + 1858
83 libR.dylib 0x000000010674562e Rf_eval + 1550
84 libR.dylib 0x000000010679ebe3 do_begin + 451
85 libR.dylib 0x000000010674562e Rf_eval + 1550
86 libR.dylib 0x000000010679cf2e R_execClosure + 926
87 libR.dylib 0x000000010679cb25 R_execMethod + 613
88 methods.so 0x00000001088946cd R_dispatchGeneric + 2173
89 libR.dylib 0x00000001067e1cda do_standardGeneric + 634
90 libR.dylib 0x00000001067456a8 Rf_eval + 1672
91 libR.dylib 0x000000010679bcb8 Rf_applyClosure + 1400
92 libR.dylib 0x0000000106745537 Rf_eval + 1303
93 libR.dylib 0x00000001067cfae3 Rf_ReplIteration + 675
94 libR.dylib 0x00000001067d0fe5 R_ReplConsole + 149
95 libR.dylib 0x00000001067d0f19 run_Rmainloop + 73
96 R 0x000000010669af3b main + 27
97 libdyld.dylib 0x00007fff95d9d5c9 start + 1
98 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type JNFException
Abort trap: 6

Coarse classing based on weight of evidence in r [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can we use weight of evidence for binning continuous data in R. For e.g. I have a data:
Recency
364
91
692
13
126
4
40
93
13
33
262
12
136
21
88
16
4
19
24
89
36
5
274
125
740
6
13
715
591
443
104
853
260
125
62
357
559
155
163
16
433
91
1380
96
374
130
574
101
5
11
34
401
13
215
168
So, what should be the command to bin this variable in different groups, based on Weight of evidence, or you can say coarse classing.
Output I want is:
Group I: Recency <200
Group I: Recency 200-400
Group I: Recency >400
Thanks
cut(df$Recency, breaks = c(0, 200, 400, +Inf))
Recency gr
1 364 (200,400]
2 91 (0,200]
3 692 (400,Inf]
4 13 (0,200]
5 126 (0,200]
6 4 (0,200]
7 40 (0,200]
8 93 (0,200]
9 13 (0,200]
10 33 (0,200]
11 262 (200,400]
12 12 (0,200]
13 136 (0,200]
14 21 (0,200]
15 88 (0,200]
16 16 (0,200]
17 4 (0,200]
18 19 (0,200]
19 24 (0,200]
20 89 (0,200]
21 36 (0,200]
22 5 (0,200]
23 274 (200,400]
24 125 (0,200]
25 740 (400,Inf]
26 6 (0,200]
27 13 (0,200]
28 715 (400,Inf]
29 591 (400,Inf]
30 443 (400,Inf]
31 104 (0,200]
32 853 (400,Inf]
33 260 (200,400]
34 125 (0,200]
35 62 (0,200]
36 357 (200,400]
37 559 (400,Inf]
38 155 (0,200]
39 163 (0,200]
40 16 (0,200]
41 433 (400,Inf]
42 91 (0,200]
43 1380 (400,Inf]
44 96 (0,200]
45 374 (200,400]
46 130 (0,200]
47 574 (400,Inf]
48 101 (0,200]
49 5 (0,200]
50 11 (0,200]
51 34 (0,200]
52 401 (400,Inf]
53 13 (0,200]
54 215 (200,400]
55 168 (0,200]

Resources