This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
11/8/2021
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
This lecture is designed to show you the potential for using R for spatial analysis when applied to historical questions.
You must have the following installed on your computer to use the code shown in this lecture:
The link to this lecture is available here <>
The following packages will also be utilised: ‘sf’, ‘tmap’, ‘tmaptools’, ‘lubridate’, ‘tidyverse’, ‘ggthemes’.
Open RStudio, in the console type
getwd()
## [1] "/Users/jackkavanagh/Dropbox/R_HY694"
Use the download link provided here, download the file marked ‘HY694.RData’ and place this within your Working Directory folder.
If you have successfully added the RData file to your working directory, when you load it a large number of files will appear in your Environment window.
The code is as follows:
read.csv('census.csv', stringsAsFactors = F,
na.strings= c("NA", " ", "")) -> census
library(tidyverse) library(sf) library(tmap) library(tmaptools)
head(census)
## Curragh_Service Regimental.Number Age Age_Ranges ## 1 No 8055 40 40-9 ## 2 No 14664 Res. (30290) 40 40-9 ## 3 No 26242 19 Under 20 ## 4 No 30990 34 30-9 ## 5 No 16154 23 20-9 ## 6 No 24274 21 20-9 ## Barracks...Post Date.of.Attestation Rank Rank_Type ## 1 Tralee 1922-08-04 Volunteer Enlisted Men ## 2 Ennis 1922-09-13 Private Enlisted Men ## 3 Ballymakeera 1922-04-08 Sergeant NCO ## 4 Loughrea 1922-05-02 Private Enlisted Men ## 5 Baldonnel 1922-05-25 Sergeant NCO ## 6 Glanmire Bridge, County Cork 1922-08-15 Volunteer Enlisted Men ## Corps Division Command ## 1 Kerry No. 1 <NA> Kerry ## 2 Engineers Home Barracks 1st Western ## 3 Armoured Car Driver 1st Eastern Division Southern Command ## 4 Infantry 1st Western Division 1st Western Command ## 5 Infantry 1st Eastern Division Eastern Command ## 6 Infantry Southern Division Cork Command ## No..on.Pay.Book Home.Address County ## 1 <NA> Ballymullen, Tralee, Kerry Kerry ## 2 14664 Barrack Street, Ennis, Clare Clare ## 3 3313 Bohermore, Galway Galway ## 4 RG 11817 Eyrecourt, Ballinasloe, Galway Galway ## 5 39027 Cloghran, Dublin Dublin ## 6 3075 Grange, Kilmore, Wexford Wexford ## Place.of.Attestation PLCounty Next.of.Kin NOK_Type NOKCounty ## 1 Tralee Kerry Child Child Kerry ## 2 Ennis Clare Child Child Clare ## 3 Ennis Clare Friend Friend Galway ## 4 Portumna Galway Friend Friend Galway ## 5 Swords Dublin Friend Friend Dublin ## 6 Cork Cork Friend Friend Wexford ## Marital.Status Religion Date.of.Attestation.Month MONTH_NKCTY ## 1 Widower Roman Catholic <NA> <NA> ## 2 Widower Roman Catholic <NA> <NA> ## 3 Single Roman Catholic <NA> <NA> ## 4 Single Roman Catholic <NA> <NA> ## 5 Single Roman Catholic <NA> <NA> ## 6 Single Roman Catholic <NA> <NA> ## MONTH_PLCTY ## 1 <NA> ## 2 <NA> ## 3 <NA> ## 4 <NA> ## 5 <NA> ## 6 <NA>
tail(census)
## Curragh_Service Regimental.Number Age Age_Ranges Barracks...Post ## 31464 No 28116 (61) 24 20-9 Bansha ## 31465 <NA> <NA> 26 20-9 Valentia Island ## 31466 No 7752 25 20-9 Valentia Island ## 31467 Yes 20589 (19867 R.) 22 20-9 Boyle ## 31468 No 7610 45 40-9 Valentia ## 31469 No 28113 (433) 30 30-9 Bansha ## Date.of.Attestation Rank Rank_Type Corps ## 31464 1922-07-27 Private Enlisted Men Infantry ## 31465 1922-08-28 Captain Officer I.O. ## 31466 1922-10-24 Volunteer Enlisted Men Infantry ## 31467 1922-06-25 Sergeant NCO Staff ## 31468 1922-09-12 Volunteer Enlisted Men Infantry ## 31469 1922-07-26 Private Enlisted Men Infantry ## Division Command No..on.Pay.Book ## 31464 4th Southern Division South Western Command 11535 ## 31465 <NA> Kerry Command 40899 ## 31466 <NA> Kerry Command 40853 ## 31467 3rd Western Division Western Command 9867 ## 31468 <NA> Kerry Command 40855 ## 31469 4th Southern Division South Western Command 14807 ## Home.Address County ## 31464 7 Walsh's Lane, off Edward Street, Limerick Limerick ## 31465 Church Street, Cahirciveen, Kerry Kerry ## 31466 High Street, Cahirciveen Kerry ## 31467 26 Barlow Street, Bradford, Manchester England ## 31468 High Street, Cahirciveen, Kerry Kerry ## 31469 21 Garveys Range, Limerick Limerick ## Place.of.Attestation PLCounty Next.of.Kin NOK_Type ## 31464 Limerick Limerick Wife & 2 Children Wife ## 31465 Cahirciveen Kerry Wife & 2 Children Wife ## 31466 Cahirciveen Kerry Wife & 2 Children Wife ## 31467 Boyle Roscommon Wife & Child Wife ## 31468 Cahirciveen Kerry Wife & Children Wife ## 31469 Limerick Limerick Wife & Three Children Wife ## NOKCounty Marital.Status Religion Date.of.Attestation.Month ## 31464 Limerick Married Roman Catholic <NA> ## 31465 Kerry Married Roman Catholic <NA> ## 31466 Kerry Married Roman Catholic <NA> ## 31467 England Married Roman Catholic <NA> ## 31468 Kerry Married Roman Catholic <NA> ## 31469 Limerick Married Roman Catholic <NA> ## MONTH_NKCTY MONTH_PLCTY ## 31464 <NA> <NA> ## 31465 <NA> <NA> ## 31466 <NA> <NA> ## 31467 <NA> <NA> ## 31468 <NA> <NA> ## 31469 <NA> <NA>