-
Notifications
You must be signed in to change notification settings - Fork 0
/
places_lived.Rmd
567 lines (467 loc) · 15.2 KB
/
places_lived.Rmd
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
---
title: "Places I have lived"
# author: "Stuart Leeds"
date: "2021-07-14"
output:
html_document:
toc: FALSE
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE, # set to TRUE to allow code chunks to "print" in output
message = FALSE,
warning = FALSE,
fig.align='center'
)
```
> It occurred to me that I have lived in many places during my lifetime. This is
> a basic run-down of them all, giving rough locations as coordinates. I might
> return to it at some point and add dates, but this will do for now.
[`Code` available
here](https://github.com/sleeds50/my_website/blob/main/places_lived.Rmd)^[Feel
free to use it and change details to suit your needs - or improve it (if you do,
please email me to say how you did it better - we're all learning, right?)]
```{r libraries}
# load libraries
library(tidyverse)
library(maps)
library(mapproj)
library(leaflet)
library(kableExtra)
library(ggrepel)
```
# 1. Locations
Table 1 lists the places I have lived. Let me state that it only includes places
where I have lived with parents as a child and young adult (see items 1:8); and
places that I have officially rented or mortgaged as an adult (items 9:end).
Furthermore, if memory serves, we lived in two properties in Kuwait, two in
Bahrain; and I lived in Chertsey more than once; and rented twice in Addlestone.
I have not included sofa-surfing or temporary dwellings.
Table 1 also shows the order of properties lived in, from birth to now
(some 50-ish years later!)
```{r dwellings}
# create data frame
dwellings <- data.frame(
List = 1:18,Address = c(
"Abridge, Essex",
"Stansted, Essex",
"Kuwait City, Kuwait",
"Manama, Bahrain",
"Pilgrims Hatch, Essex",
"Chertsey, Surrey",
"Stradishall, Suffolk",
"Cowlinge, Suffolk",
"Addlestone, Surrey",
"Twickenham, Middlesex",
"Twickenham, Middlesex",
"Bedfont Green, Middlesex",
"Jaywick, Essex",
"Harwich, Essex",
"Harwich, Essex",
"Ipswich, Suffolk",
"Bath, Somerset",
"Bath, Somerset"
),
Latitude = c(
51.651447,
51.9070471,
29.3797091,
26.2235041,
51.6357161,
51.378971,
52.139740,
52.158376,
51.371280,
51.438541,
51.434900,
51.450761,
51.776301,
51.933189,
51.932645,
52.068666,
51.394750,
51.392352
),
Longitude = c(
0.124044,
0.2017505,
47.9735629,
50.5822436,
0.2945186,
-0.520269,
0.516622,
0.506907,
-0.489646,
-0.336711,
-0.332810,
-0.439600,
1.119079,
1.274589,
1.275031,
1.130408,
-2.388744,
-2.384639
)
)
```
```{r main table, }
# print a table to see the information at a glance, instead of having the reader try to
# find and link each row in the format above.
dwellings |>
kbl(caption = "<b>Table 1</b><br> <i>Places I have lived</i>") |>
kable_classic_2(full_width = FALSE, position = "center")
```
```{r mean coords}
# These next two code-chunks create the variables for the mean and median coordinates,
# which come in handy later on when we plot them.
# mean coordinates used for world map and table 2
meanCoords <- data.frame(
row.names = c(
"Worldwide",
"England"
),
Latitude = c(
mean(dwellings$Latitude), # World
mean(dwellings[-c(3:4), ]$Latitude) # England
),
Longitude = c(
mean(dwellings$Longitude), # World
mean(dwellings[-c(3:4), ]$Longitude) # England
),
Place = c(
"Génicourt-sur-Meuse, France",
"Cheshunt, Hertfordshire, England"
)
)
```
```{r median coords}
# median coordinates used for world map and table 3
medianCoords <- data.frame(
row.names = c(
"Worldwide",
"England"
),
Latitude = c(
median(dwellings$Latitude), # World
median(dwellings[-c(3:4), ]$Latitude) # England
),
Longitude = c(
median(dwellings$Longitude), # World
median(dwellings[-c(3:4), ]$Longitude) # England
),
Place = c(
"Upminster, Essex, England",
"Stapleford Abbotts, Essex, England"
)
)
```
# 2. Interactive map
The coordinates are pin-pointed on a world map (use +/- zoom functions and
left-click[hold]/drag to pan). Hover cursor over circles for labels.
* __Green circles:__ points of all places lived.
* __Blue circles:__ _mean_ average location of ALL coordinates in _Table 1_
(see _Table 2_ for details)
* __Red circles:__ _median_ average locations of ALL coordinates in _Table 1_
(see _Table 3_ for details)
```{r map}
# plot coordinates on the world map
# whole table
worldMap <- with(dwellings, leaflet(width = 900) |>
addTiles() |>
addCircleMarkers(
lng = Longitude,
lat = Latitude,
color = "green", label = List
)) |>
# mean coordinates of World locations
addCircleMarkers(
lng = meanCoords[1, 2],
lat = meanCoords[1, 1], color = "blue", label = "World mean",
) |>
# mean coordinates of England locations
addCircleMarkers(
lng = meanCoords[2, 2],
lat = meanCoords[2, 1], color = "blue", label = "England mean"
) |>
# median coordinates of World locations
addCircleMarkers(
lng = medianCoords[1, 2],
lat = medianCoords[1, 1], color = "red", label = "World median"
) |>
# median coordinates of England locations
addCircleMarkers(
lng = medianCoords[2, 2],
lat = medianCoords[2, 1], color = "red", label = "England median"
)
worldMap
```
# 3a. Static plots
## Global view of places lived
```{r map worldwide plot}
# all locations
ggplot(dwellings, aes(x = Longitude, y = Latitude)) +
geom_point(
pch = 19,
colour = dwellings$List,
size = 2
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coordinate plot 1: Worldwide locations",
caption = "Note. Coordinates intercept at Greenwich, London"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
## The spread of locations in England
```{r map uk plot}
# all England locations
ggplot(dwellings, aes(x = Longitude, y = Latitude)) +
xlim(-2.5, 1.5) +
ylim(51, 52.5) +
geom_point(
colour = dwellings$Latitude,
size = 3
) +
geom_text_repel(
label = dwellings$List
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coodinate plot 2: England",
caption = "Note. Coordinates intercept at Greenwich, London."
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
You can see that most of the places lived in England have been between
$51^{\circ}$ and $52^{\circ}$ latitude, with a brief sojourn above the $52nd$
parallel (although I spent around five years living in Ipswich (16)); and
between $-2.5^{\circ}$ and $1.5^{\circ}$ longitude (quite a small area,
considering).
- The numbers represent the order in which the places were lived and coincide
with Table 1 above.
It is interesting that, although numerous; and despite the huge leap between
locations 2 and 5 (3 and 4 abroad, see main map above), the places lived are in
relatively tight clusters suggesting that I've enjoyed a local familiarity for a
while before needing/having to move on.
The clusters are divided across counties, as follows.
# 3b. Breaking down into counties:
## Essex and Suffolk
```{r map Essex plot}
# Essex and Suffolk
ggplot(dwellings, aes(x = Longitude, y = Latitude)) +
xlim(-0.1, 1.3) +
ylim(51.4, 52.2) +
geom_point(
colour = dwellings$List,
size = 3
) +
geom_text_repel(
label = dwellings$List
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coodinate plot 3: Essex and Suffolk",
caption = "Note. Coordinates intercept at Greenwich, London"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
## Surrey and Middlesex
```{r map Surrey/middx plot}
# Surrey and Middlesex
ggplot(dwellings, aes(x = Longitude, y = Latitude)) +
xlim(-0.55, 0.001) +
ylim(51.35, 51.49) +
geom_point(
colour = dwellings$List,
size = 3
) +
geom_text_repel(
label = dwellings$List
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coodinate plot 4: Surrey/Middlesex",
caption = "Note. Coordinates intercept at Greenwich, London"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
## Somerset
There's little point presenting a plot with two points on it, so Coordinate
plot 5 below shows the locations in Surrey/Middlesex and Somerset and the
expanse between.
```{r map Bath plot}
# Somerset
ggplot(dwellings, aes(x = Longitude, y = Latitude)) +
xlim(-2.4, 0.01) +
ylim(51.3, 51.5) +
geom_point(
colour = dwellings$List,
size = 3
) +
geom_text_repel(
label = dwellings$List
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coodinate plot 5: London to Somerset",
caption = "Note. Coordinates intercept at Greenwich, London"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
# 3c. Mean and Median locations
## Mean coordinates
I thought it would be interesting to know the mean and median locations of where
I have lived in the world; and in England.
Table 2 shows the mean coordinates of both the worldwide; and the England
locations from Table 1. In my mind, these give an indication of where I should
be living according to the mean-average coordinates of where I actually *have*
lived.
```{r mean coords table}
# mean coordinates
meanCoords |>
kbl(caption = "<b>Table 2</b><br> <i>Average coordinates (mean)</i>") |>
kable_classic_2(full_width = FALSE, position = "center")
```
```{r mean coords plot}
# mean coords plot
ggplot(meanCoords, aes(x = Longitude, y = Latitude)) +
xlim(-1, 10) +
ylim(49, 53) +
geom_point(
colour = "blue",
size = 5
) +
geom_text_repel(
label = meanCoords$Place,
nudge_x = 3, nudge_y = 0.5
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
labs(
title = "Coodinate plot 6: the average (mean) of all coordinates",
caption = "Note. Coordinates intercept at Greenwich, London
Cheshunt= England dwelling mean
Génicourt-sur-Meuse= World dwelling mean"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
I must admit, I quite fancy **Génicourt-sur-Meuse, France**. I've never been
there, but it sounds like it would suit me. Ironically, I worked in Cheshunt for
a fair while until I was made redundant, though I didn't miss the daily journey
from Harwich and back which became a drag after about 5 years of working for the
company there.
## Median coordinates
Table 3 shows the median coordinates of both the worldwide; and the England
locations from Table 1.
So, technically, these will be the absolute mid-point places to live according
to both options.
```{r median coords table}
# median coordinates
medianCoords |>
kbl(caption = "<b>Table 3</b><br> <i> Average coordinates (median)</i>") |>
kable_classic_2(full_width = FALSE, position = "center")
```
```{r med coords plot}
# median coordinates plot
ggplot(medianCoords, aes(x = Longitude, y = Latitude)) +
xlim(-1, 2.5) +
ylim(51, 52) +
geom_point(
colour = "red",
size = 5
) +
geom_text_repel(
label = medianCoords$Place,
nudge_x = 1, nudge_y = 0.1
) +
coord_map(projection = "globular") +
geom_vline(xintercept = -0.0076589) +
geom_hline(yintercept = 51.4825766) +
geom_point(x = 0.176, y = 51.5655, pch = 8, size = 2) +
labs(
title = "Coodinate plot 7: the average (median) of all coordinates",
caption = "Note. Coordinates intercept at Greenwich, London
* = Rush Green, Dagenham
Stapleford Abbotts= England dwelling median
Upminster= World dwelling median"
) +
theme(plot.caption = element_text(hjust = 0, face = "italic"))
```
<br>
> *Note.* The irony of the median coordinate plot is that both locations from
> the worldwide and England coordinates are a stones throw from where I was
> born! (Shown with an asterisk on the map above).
<br>
## Distances from the median locations to where I was born
So for fun, we'll use the `distm` function from the `geosphere` package to
calculate the distances between coordinates in metres (tutorial found on
[Statistics
Globe](https://statisticsglobe.com/geospatial-distance-between-two-points-in-r)
- actually a good site and recommended for many explanations of R-functions).
Once installed and loaded, I realised I needed another variable to hold the
\_Rush Green \_ coordinates. Then, I found out that `distm` needs the longitude
and latitude in that order, so had to reverse the two columns in my original
mean/median variables, then combined the two new variables into one, for each.
So the calculation returns like this for Stapleford Abbot:
```{r distance between- setup}
# install.packages("geosphere") for calculating distance between coordinates
# load additional "geosphere" library
library(geosphere)
# create rush_green coordinate variable
rush_green <- c(Longitude = 0.176,
Latitude = 51.5655,
Place = "Dagenham, Essex, England")
# create new median coords variable and swap long. and lat. variables because that's
# how `distm` likes it
median_coord_swap <- medianCoords |>
relocate(Longitude, .before = Latitude)
# and combine row 2 with rush_to_stapleford variable
rush_to_stapleford <- median_coord_swap[2,] |>
rbind(rush_green)
# calculate distance between median places (Apply distm function)
dist_median <- distm(rush_to_stapleford[, 1:2], fun = distGeo)
# Print distance matrix
dist_median
```
...and this for Upminster...
```{r distance between- calc}
# new rush_to_upminster variable combined with row 1 of median swap variable
rush_to_upminster <- median_coord_swap[1,] |>
rbind(rush_green)
# calculate mean distance
dist_mean <- distm(rush_to_upminster[, 1:2], fun = distGeo)
# print matrix
dist_mean
```
## Summary
Remember the distances are in metres - I used [this
website](https://www.convertunits.com/from/meters/to/miles) (others are
available!) to convert the distances into miles (not sure if the site specifies
US miles as others have done, or my preferred UK miles, however...)
It's enough to give a guide to how close *Rush Green* is...
to the median of places in England:
> __Stapleford Abbotts = 8.73Km (5.43 miles) away.__
to the median of worldwide locations:
> __Upminster = 5.58Km (3.47 miles) away.__
This has been an interesting project - thanks for reading. I might take it
further one day and tell the story of each place and why I moved so many times.
I'm sure that the average moves during a lifetime is far fewer than what I have
achieved here. Does it mean I haven't settled anywhere? Or is it acting on
circumstances? A mixture of both? Why have I laid my hat in; and called so many
different locations, home?
(Social) psychology would describe these transitional moments of upheaval as
*ruptures* [(Zittoun, 2006,
p. 5)](https://www.google.co.uk/books/edition/Transitions/ivgnDwAAQBAJ?hl=en&gbpv=1&pg=PR1&printsec=frontcover),
since they can cause stress and disruption to 'normal' life (whatever *that*
is). Maybe that explains a few things!