A Tightrope Called Desire
I walk the line in many ways. Being biracial and bisexual, I suppose it’s in my nature.
I’ve learned that there’s a thin line between happy and sad, okay and not. And because of that, I find the edge is the safest place to be. If you’re comfortable living on the edge, there’s no need to ever fall over it. The strange but rewarding compromise between reckless and responsible is what keeps me somewhat sane. And what is balance, other than the average of two extremes?
In 2019, I lived a little extremely, visiting Japan three times within a span of 6 months when I’d never been there before. In 2020, I’ll spend at least 6 months of the year not traveling at all. Balanced I’ll let you decide that. Just as I’ll let you decide the places between which you want to draw a line using the maptools and geosphere packages in R.
I adapted some code posted by Paulo E. Cardozo on Stack Overflow to make the visual you see above.
If you’re like me, you probably have old versions of the packages you need for this installed. And you probably forgot about it. To reset them, you can use the code below:
renew <- c("ggmap", 'sp','rgdal', 'maptools', 'geosphere')
renew.packs <- renew[!(renew %in% installed.packages()[,"Package"])]
if(length(renew.packs)) install.packages(renew.packs)
lapply(renew, require, character.only=T)
remove(renew, renew.packs)
Now your new packages will be ready to great the spatial data frame you need.
data(wrld_simpl)
US_lat = wrld_simpl$LAT[wrld_simpl$NAME == 'United States']
US_lon = wrld_simpl$LON[wrld_simpl$NAME == 'United States']
Jap_lat = wrld_simpl$LAT[wrld_simpl$NAME == 'Japan']
Jap_lon = wrld_simpl$LON[wrld_simpl$NAME == 'Japan']
This loads the data you want. Play around with different countries as you see fit. Where do you miss the most? I could definitely use two meals worth of dumplings from Kyoto’s Tiger Gyoza and a walk down Pontocho Alley ending at my favorite hidden wine bar Bar Nattsun.
The following code will help you locate the points you need to plot your graph and line:
points = gcIntermediate(c(US_lon, US_lat), c(SWE_lon, SWE_lat), n=10, addStartEnd=T)
And all that’s left to do is plot the graph like I did in the visual above. Feel free to tweet your graphs to me at @dikayodata. I want to know which places are in your mind’s view and how you like the packages.
Like what you read?
Promote the creation and circulation of more interesting tutorials by becoming a patron of Dikayo Data! Even the lowest tier will get you access to unique bonus content, centered around anything from diversity and inclusion to webinar discounts.