├── .gitattributes ├── .gitignore ├── Docker_Build.sh ├── Docker_Make.sh ├── Docker_Make_WinPowerShell.sh ├── Docker_RStudio_Start.sh ├── Docker_RStudio_Start_WinPowerShell.sh ├── Docker_RStudio_Stop.sh ├── Dockerfile ├── LICENSE ├── Make.R ├── Make_Clean.R ├── README.md ├── data └── README.md ├── granolarr.Rproj └── src ├── docker_config └── Requirements.R ├── lectures ├── 101_L_Introduction.Rmd ├── 102_L_CoreConcepts.Rmd ├── 103_L_Tidyverse.Rmd ├── 111_L_DataTypes.Rmd ├── 112_L_ControlStructures.Rmd ├── 113_L_Functions.Rmd ├── 201_L_DataFrames.Rmd ├── 202_L_SelectionFiltering.Rmd ├── 203_L_DataManipulation.Rmd ├── 211_L_DataJoin.Rmd ├── 212_L_TidyData.Rmd ├── 213_L_ReadWrite.Rmd ├── 221_L_Reproducibility.Rmd ├── 222_L_RMarkdown.Rmd ├── 223_L_Git.Rmd ├── 301_L_DataVisualisation.Rmd ├── 302_L_DescriptiveStats.Rmd ├── 303_L_ExploringAssumptions.Rmd ├── 311_L_ComparingMeans.Rmd ├── 312_L_Correlation.Rmd ├── 313_L_DataTransformations.Rmd ├── 321_L_Regression.Rmd ├── 322_L_RegressionMultiple.Rmd ├── 323_L_RegressionComparing.Rmd ├── 401_L_MachineLearningIntro.Rmd ├── 402_L_NeuralNetworks.Rmd ├── 403_L_SupportVectorMachines.Rmd ├── 411_L_PrincipalComponents.Rmd ├── 412_L_ClusteringCentroid.Rmd ├── 413_L_ClusteringHierarchicalDensity.Rmd ├── contents │ ├── 101_L_Introduction.Rmd │ ├── 102_L_CoreConcepts.Rmd │ ├── 103_L_Tidyverse.Rmd │ ├── 111_L_DataTypes.Rmd │ ├── 112_L_ControlStructures.Rmd │ ├── 113_L_Functions.Rmd │ ├── 201_L_DataFrames.Rmd │ ├── 202_L_SelectionFiltering.Rmd │ ├── 203_L_DataManipulation.Rmd │ ├── 211_L_DataJoin.Rmd │ ├── 212_L_TidyData.Rmd │ ├── 213_L_ReadWrite.Rmd │ ├── 221_L_Reproducibility.Rmd │ ├── 222_L_RMarkdown.Rmd │ ├── 223_L_Git.Rmd │ ├── 301_L_DataVisualisation.Rmd │ ├── 302_L_DescriptiveStats.Rmd │ ├── 303_L_ExploringAssumptions.Rmd │ ├── 311_L_ComparingMeans.Rmd │ ├── 312_L_Correlation.Rmd │ ├── 313_L_DataTransformations.Rmd │ ├── 321_L_Regression.Rmd │ ├── 322_L_RegressionMultiple.Rmd │ ├── 323_L_RegressionComparing.Rmd │ ├── 401_L_MachineLearningIntro.Rmd │ ├── 402_L_NeuralNetworks.Rmd │ ├── 403_L_SupportVectorMachines.Rmd │ ├── 411_L_PrincipalComponents.Rmd │ ├── 412_L_ClusteringCentroid.Rmd │ ├── 413_L_ClusteringHierarchicalDensity.Rmd │ ├── _book │ │ └── 321_L_Regression.md │ ├── _bookdown.yml │ └── index.Rmd └── images │ ├── 296px-Colored_neural_network.svg.png │ ├── 489px-Linear_least_squares_example2.svg.png │ ├── ANN_description.png │ ├── Colored_deep_neural_network-01.png │ ├── Colored_deep_neural_network.ai │ ├── Colored_neural_network.svg │ ├── DBSCAN-Gaussian-data.png │ ├── DockerDiagram_Docker.png │ ├── DockerDiagram_VM.png │ ├── MnistExamples.png │ ├── MnistExamples_2.png │ ├── Neuron3.png │ ├── Overfitted_Data.png │ ├── Overfitting.svg.png │ ├── PipeOperator.png │ ├── README.md │ ├── Reinforcement_learning_diagram.svg.png │ ├── Typical_cnn.png │ ├── artificial_neuron.png │ ├── git_snapshots.png │ ├── git_three_stages.png │ └── joins.png ├── practicals ├── 104_P_Introduction.Rmd ├── 114_P_RProgramming.Rmd ├── 204_P_SelectionManipulation.Rmd ├── 214_P_TableOperations.Rmd ├── 224_P_Reproducibility.Rmd ├── 304_P_Exploratory.Rmd ├── 314_P_ComparingData.Rmd ├── 324_P_Regression.Rmd ├── 324_P_Regression.log ├── 404_P_SupervisedLearning.Rmd ├── 414_P_UnsupervisedLearning.Rmd ├── contents │ ├── 104_P_Introduction.Rmd │ ├── 114_P_RProgramming.Rmd │ ├── 204_P_SelectionManipulation.Rmd │ ├── 214_P_TableOperations.Rmd │ ├── 224_P_Reproducibility.Rmd │ ├── 304_P_Exploratory.Rmd │ ├── 314_P_ComparingData.Rmd │ ├── 324_P_Regression.Rmd │ ├── 404_P_SupervisedLearning.Rmd │ ├── 414_P_UnsupervisedLearning.Rmd │ ├── _bookdown_files │ │ ├── 304_P_Exploratory_files │ │ │ ├── figure-epub3 │ │ │ │ ├── unnamed-chunk-13-1.png │ │ │ │ ├── unnamed-chunk-14-1.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ ├── unnamed-chunk-4-1.png │ │ │ │ ├── unnamed-chunk-5-1.png │ │ │ │ ├── unnamed-chunk-6-1.png │ │ │ │ └── unnamed-chunk-7-1.png │ │ │ ├── figure-html │ │ │ │ ├── unnamed-chunk-13-1.png │ │ │ │ ├── unnamed-chunk-14-1.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ ├── unnamed-chunk-4-1.png │ │ │ │ ├── unnamed-chunk-5-1.png │ │ │ │ ├── unnamed-chunk-6-1.png │ │ │ │ └── unnamed-chunk-7-1.png │ │ │ └── figure-latex │ │ │ │ ├── unnamed-chunk-13-1.pdf │ │ │ │ ├── unnamed-chunk-14-1.pdf │ │ │ │ ├── unnamed-chunk-3-1.pdf │ │ │ │ ├── unnamed-chunk-4-1.pdf │ │ │ │ ├── unnamed-chunk-5-1.pdf │ │ │ │ ├── unnamed-chunk-6-1.pdf │ │ │ │ └── unnamed-chunk-7-1.pdf │ │ ├── 314_P_ComparingData_files │ │ │ ├── figure-epub3 │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ └── unnamed-chunk-8-1.png │ │ │ ├── figure-html │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ └── unnamed-chunk-8-1.png │ │ │ └── figure-latex │ │ │ │ ├── unnamed-chunk-10-1.pdf │ │ │ │ ├── unnamed-chunk-3-1.pdf │ │ │ │ └── unnamed-chunk-8-1.pdf │ │ ├── 324_P_Regression_files │ │ │ ├── figure-epub3 │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-10-2.png │ │ │ │ ├── unnamed-chunk-10-3.png │ │ │ │ ├── unnamed-chunk-10-4.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ ├── unnamed-chunk-5-1.png │ │ │ │ └── unnamed-chunk-7-1.png │ │ │ ├── figure-html │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-10-2.png │ │ │ │ ├── unnamed-chunk-10-3.png │ │ │ │ ├── unnamed-chunk-10-4.png │ │ │ │ ├── unnamed-chunk-3-1.png │ │ │ │ ├── unnamed-chunk-5-1.png │ │ │ │ └── unnamed-chunk-7-1.png │ │ │ └── figure-latex │ │ │ │ ├── unnamed-chunk-10-1.pdf │ │ │ │ ├── unnamed-chunk-10-2.pdf │ │ │ │ ├── unnamed-chunk-10-3.pdf │ │ │ │ ├── unnamed-chunk-10-4.pdf │ │ │ │ ├── unnamed-chunk-3-1.pdf │ │ │ │ ├── unnamed-chunk-5-1.pdf │ │ │ │ └── unnamed-chunk-7-1.pdf │ │ ├── 404_P_SupervisedLearning_files │ │ │ ├── figure-epub3 │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-17-1.png │ │ │ │ └── unnamed-chunk-6-1.png │ │ │ ├── figure-html │ │ │ │ ├── unnamed-chunk-10-1.png │ │ │ │ ├── unnamed-chunk-17-1.png │ │ │ │ └── unnamed-chunk-6-1.png │ │ │ └── figure-latex │ │ │ │ ├── unnamed-chunk-10-1.pdf │ │ │ │ ├── unnamed-chunk-17-1.pdf │ │ │ │ └── unnamed-chunk-6-1.pdf │ │ └── 414_P_UnsupervisedLearning_files │ │ │ ├── figure-epub3 │ │ │ ├── figures-side-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-14-2.png │ │ │ ├── unnamed-chunk-14-3.png │ │ │ ├── unnamed-chunk-16-1.png │ │ │ ├── unnamed-chunk-17-1.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-8-2.png │ │ │ └── unnamed-chunk-8-3.png │ │ │ ├── figure-html │ │ │ ├── figures-side-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-14-2.png │ │ │ ├── unnamed-chunk-14-3.png │ │ │ ├── unnamed-chunk-16-1.png │ │ │ ├── unnamed-chunk-17-1.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ ├── unnamed-chunk-8-2.png │ │ │ └── unnamed-chunk-8-3.png │ │ │ └── figure-latex │ │ │ ├── figures-side-1.pdf │ │ │ ├── unnamed-chunk-10-1.pdf │ │ │ ├── unnamed-chunk-11-1.pdf │ │ │ ├── unnamed-chunk-12-1.pdf │ │ │ ├── unnamed-chunk-14-1.pdf │ │ │ ├── unnamed-chunk-14-2.pdf │ │ │ ├── unnamed-chunk-14-3.pdf │ │ │ ├── unnamed-chunk-16-1.pdf │ │ │ ├── unnamed-chunk-17-1.pdf │ │ │ ├── unnamed-chunk-19-1.pdf │ │ │ ├── unnamed-chunk-6-1.pdf │ │ │ ├── unnamed-chunk-8-1.pdf │ │ │ ├── unnamed-chunk-8-2.pdf │ │ │ └── unnamed-chunk-8-3.pdf │ ├── _main.Rmd │ ├── _main.log │ ├── _main.rds │ └── index.Rmd ├── images │ ├── ANOVA_output_annotated.png │ ├── PipeOperator.png │ ├── README.md │ ├── Regression_output_annotated.png │ ├── artificial_neuron.png │ ├── git_three_stages.png │ └── joins.png └── materials │ └── functions.R └── utils ├── Create_2011OAC_Leicester_dataset.R ├── Create_2011OAC_Leicester_dataset_supgrp.R ├── Create_2011OAC_Leicestershire_dataset.R ├── Create_2011OAC_Rutland_dataset.R ├── Create_2011OAC_SouthLeicestershire_dataset.R ├── Create_IMD2015_Leicester_dataset.R ├── IOSlides ├── README.md ├── UoL_Template.html ├── UoL_Template_UniColours.html ├── uol_logo.png └── uol_logo_colour.png ├── Leicester_Pride_2019.R └── RMarkdown ├── rmarkdown_classes.css └── rmarkdown_classes.tex /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-vendored 2 | *.css linguist-vendored 3 | *.js linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # Example code in package build process 9 | *-Ex.R 10 | 11 | # Output files from R CMD build 12 | /*.tar.gz 13 | 14 | # Output files from R CMD check 15 | /*.Rcheck/ 16 | 17 | # RStudio files 18 | .Rproj.user/ 19 | .here 20 | 21 | # produced documents 22 | #/README.html 23 | #/Lectures/*.pdf 24 | #/Practicals/*.pdf 25 | #/Practicals/*.tex 26 | #/Exercises/*.html 27 | #/Exercises/*.pdf 28 | 29 | # Items in Data and tmp folder 30 | /storage/* 31 | /tmp/* 32 | /tmp/* 33 | /data/* 34 | !/data/README.md 35 | 36 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 37 | .httr-oauth 38 | 39 | # knitr and R markdown default cache directories 40 | /*_cache/ 41 | /src/practicals/solutions 42 | 43 | # Temporary files created by R markdown 44 | *.utf8.md 45 | *.knit.md 46 | /README.html 47 | 48 | # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html 49 | rsconnect/ 50 | .Rproj.user 51 | 52 | # Mac DS_Store files 53 | .DS_Store 54 | -------------------------------------------------------------------------------- /Docker_Build.sh: -------------------------------------------------------------------------------- 1 | docker build --rm --force-rm -t sdesabbata/granolarr:latest -t sdesabbata/granolarr:v0.9 . -------------------------------------------------------------------------------- /Docker_Make.sh: -------------------------------------------------------------------------------- 1 | REPO_DIR=${PWD} 2 | echo "" 3 | echo "Bind mount granolarr folder from: $REPO_DIR" 4 | docker run -ti --rm --name granolarr -u rstudio -v $REPO_DIR:/home/rstudio/granolarr sdesabbata/granolarr:v0.9 Rscript /home/rstudio/granolarr/Make.R /home/rstudio/granolarr 5 | -------------------------------------------------------------------------------- /Docker_Make_WinPowerShell.sh: -------------------------------------------------------------------------------- 1 | $REPO_DIR=${PWD} 2 | Write-Output "" 3 | Write-Output "Bind mount granolarr folder from: $REPO_DIR" 4 | docker run -ti --rm --name granolarr -u rstudio -v ${REPO_DIR}:/home/rstudio/granolarr sdesabbata/granolarr Rscript /home/rstudio/granolarr/Make.R /home/rstudio/granolarr 5 | -------------------------------------------------------------------------------- /Docker_RStudio_Start.sh: -------------------------------------------------------------------------------- 1 | REPO_DIR=${PWD} 2 | echo "" 3 | echo "Creating my_granolarr folder in parent directory (if it doesn't exist)" 4 | mkdir -p $REPO_DIR/../my_granolarr 5 | echo "Run container, bind mount my_granolarr folder" 6 | docker run -d --rm -p 28787:8787 --name granolarr -v $REPO_DIR:/home/rstudio/granolarr -v $REPO_DIR/../my_granolarr:/home/rstudio/my_granolarr sdesabbata/granolarr -------------------------------------------------------------------------------- /Docker_RStudio_Start_WinPowerShell.sh: -------------------------------------------------------------------------------- 1 | $REPO_DIR=${PWD} 2 | Write-Output "" 3 | Write-Output "Creating my_granolarr folder in parent directory (if it doesn't exist)" 4 | mkdir -p ${REPO_DIR}/../my_granolarr 5 | Write-Output "Run container, bind mount my_granolarr folder" 6 | docker run -d --rm -p 28787:8787 --name granolarr -v ${REPO_DIR}:/home/rstudio/granolarr -v ${REPO_DIR}/../my_granolarr:/home/rstudio/my_granolarr sdesabbata/granolarr -------------------------------------------------------------------------------- /Docker_RStudio_Stop.sh: -------------------------------------------------------------------------------- 1 | docker stop granolarr -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Base image https://hub.docker.com/r/rocker/ml 2 | FROM rocker/geospatial:4.0.2 3 | 4 | # create an R user 5 | ENV USER rstudio 6 | 7 | # Install additional required R libraries 8 | COPY ./src/docker_config/Requirements.R /tmp/Requirements.R 9 | RUN Rscript /tmp/Requirements.R 10 | 11 | # Update tlmgr 12 | RUN tlmgr update --self 13 | 14 | # Install additional required TeX libraries 15 | RUN tlmgr install amsmath 16 | RUN tlmgr install latex-amsmath-dev 17 | RUN tlmgr install iftex 18 | RUN tlmgr install euenc 19 | RUN tlmgr install fontspec 20 | RUN tlmgr install tipa 21 | RUN tlmgr install unicode-math 22 | RUN tlmgr install xunicode 23 | RUN tlmgr install kvoptions 24 | RUN tlmgr install ltxcmds 25 | RUN tlmgr install kvsetkeys 26 | RUN tlmgr install etoolbox 27 | RUN tlmgr install xcolor 28 | RUN tlmgr install atbegshi 29 | RUN tlmgr install atveryend 30 | RUN tlmgr install auxhook 31 | RUN tlmgr install bigintcalc 32 | RUN tlmgr install bitset 33 | RUN tlmgr install etexcmds 34 | RUN tlmgr install gettitlestring 35 | RUN tlmgr install hycolor 36 | RUN tlmgr install hyperref 37 | RUN tlmgr install intcalc 38 | RUN tlmgr install kvdefinekeys 39 | RUN tlmgr install letltxmacro 40 | RUN tlmgr install pdfescape 41 | RUN tlmgr install refcount 42 | RUN tlmgr install rerunfilecheck 43 | RUN tlmgr install stringenc 44 | RUN tlmgr install uniquecounter 45 | RUN tlmgr install zapfding 46 | RUN tlmgr install pdftexcmds 47 | RUN tlmgr install infwarerr 48 | RUN tlmgr install fancyvrb 49 | RUN tlmgr install framed 50 | RUN tlmgr install booktabs 51 | RUN tlmgr install mdwtools 52 | RUN tlmgr install grffile 53 | RUN tlmgr install geometry 54 | RUN tlmgr install epstopdf-pkg 55 | -------------------------------------------------------------------------------- /Make_Clean.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # Make clean file in R 3 | # Author: Stefano De Sabbata 4 | # Date: 12 July 2019 5 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 6 | ########## 7 | 8 | # Load necessary libraries 9 | library(here) 10 | 11 | # Clean R Environment 12 | 13 | rm(list = ls()) 14 | 15 | # Delete compiled files from R Markdown scripts 16 | 17 | unlink(here("src/lectures/contents/_main.rds")) 18 | unlink(here("src/lectures/contents/_main.md")) 19 | unlink(here("src/lectures/contents/_main.html")) 20 | unlink(here("src/lectures/contents/_main.tex")) 21 | unlink(here("src/lectures/contents/_main.log")) 22 | unlink(here("src/lectures/contents/_main.pdf")) 23 | unlink(here("src/lectures/contents/_bookdown_files"), recursive = TRUE) 24 | #unlink(here("lectures/html/*.html")) 25 | #unlink(here("lectures/bookdown"), recursive = TRUE) 26 | unlink(here("docs/lectures/html/*.html")) 27 | unlink(here("docs/lectures/bookdown"), recursive = TRUE) 28 | 29 | unlink(here("src/practicals/contents/_main.rds")) 30 | unlink(here("src/practicals/contents/_main.md")) 31 | unlink(here("src/practicals/contents/_main.html")) 32 | unlink(here("src/practicals/contents/_main.tex")) 33 | unlink(here("src/practicals/contents/_main.log")) 34 | unlink(here("src/practicals/contents/_main.pdf")) 35 | unlink(here("src/practicals/contents/_bookdown_files"), recursive = TRUE) 36 | #unlink(here("practicals/pdf/*.pdf")) 37 | #unlink(here("practicals/pdf/*.tex")) 38 | #unlink(here("practicals/bookdown"), recursive = TRUE) 39 | unlink(here("docs/practicals/pdf/*.pdf")) 40 | unlink(here("docs/practicals/pdf/*.tex")) 41 | unlink(here("docs/practicals/bookdown"), recursive = TRUE) -------------------------------------------------------------------------------- /data/README.md: -------------------------------------------------------------------------------- 1 | # Data 2 | 3 | *[Stefano De Sabbata](https://stefanodesabbata.com)* 4 | 5 | [This work](https://github.com/sdesabbata/granolarr) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html) except where specified. 6 | 7 | The data used in these materials are derived from data released by the [Office for National Statistics](https://geoportal.statistics.gov.uk/), [Chris Gale](http://geogale.github.io/2011OAC/) ([Office for National Statistics](https://geoportal.statistics.gov.uk/)), the [ESRC Consumer Data Research Centre](https://data.cdrc.ac.uk/), the [Ministry of Housing, Communities & Local Government](https://opendatacommunities.org/home) and the [UK Data Service](https://ukdataservice.ac.uk/), licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/); contains National Statistics data Crown copyright and database right 2015; contains Ordnance Survey data Crown copyright and database right 2015 and 2016. 8 | 9 | ## Get the data 10 | 11 | Please create a `storage` folder in the main repository folder before following the instructions below. 12 | 13 | - [OA11_LSOA11_MSOA11_LAD11_EW_LU.zip](https://borders.ukdataservice.ac.uk/lut_download_data.html?data=oa11_lsoa11_msoa11_lad11_ew_lu) 14 | - Source: [UK Data Service](https://ukdataservice.ac.uk/) licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). 15 | - Pre-processing: 16 | - download in the `storage` folder. 17 | - [2011 OAC Variables - 167 Initial.zip](http://tiny.cc/OAC-Var-167) 18 | - Source: [Chris Gale](http://geogale.github.io/2011OAC/) ([Office for National Statistics](https://geoportal.statistics.gov.uk/)), licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). 19 | - Pre-processing: 20 | - download in the `storage` folder; 21 | - run the `src/utils/Create_2011OAC_Leicester_dataset.R` script. 22 | - [Indexes of Multiple deprivation 2015](https://opendatacommunities.org/resource?uri=http%3A%2F%2Fopendatacommunities.org%2Fdata%2Fsocietal-wellbeing%2Fimd%2Findices) 23 | - Source: [Ministry of Housing, Communities & Local Government](https://opendatacommunities.org/home) licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). 24 | - Pre-processing: 25 | - download in the `storage` folder; 26 | - rename the column `Indices of Deprivation` as `IndicesOfDeprivation`; 27 | - run: `src/utils/Create_IMD2015_Leicester_dataset.R`. 28 | - CDRC's [Census Residential Data Pack 2011: Leicester](https://data.cdrc.ac.uk/system/files/Census_Residential_Data_Pack_2011/Census_Residential_Data_Pack_2011_E06000016.zip) 29 | - Source: [ESRC Consumer Data Research Centre](https://data.cdrc.ac.uk/) licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/); Contains National Statistics data Crown copyright and database right 2015; Contains Ordnance Survey data Crown copyright and database right 2015. 30 | - Pre-processing: 31 | - download in the `data` folder. 32 | - [Rural Urban Classification (2011) of Output Areas in England and Wales](https://geoportal.statistics.gov.uk/datasets/3ce248e9651f4dc094f84a4c5de18655/about) 33 | - Source: [Office for National Statistics](https://geoportal.statistics.gov.uk/) licensed under the [Open Government Licence v.3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/); Contains OS data © Crown copyright and database right 2016. 34 | - Pre-processing: 35 | - download in the `data` folder. 36 | -------------------------------------------------------------------------------- /granolarr.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: XeLaTeX 14 | -------------------------------------------------------------------------------- /src/docker_config/Requirements.R: -------------------------------------------------------------------------------- 1 | # # Install additional libraries 2 | 3 | install.packages("here") 4 | install.packages("car") 5 | install.packages("caret") 6 | install.packages("pastecs") 7 | install.packages("psych") 8 | install.packages("lm.beta") 9 | install.packages("lmtest") 10 | install.packages("DescTools") 11 | install.packages("dbscan") 12 | install.packages("stargazer") 13 | install.packages("ggmap") 14 | install.packages("ggthemes") 15 | install.packages("GGally") 16 | install.packages("patchwork") 17 | install.packages("factoextra") 18 | install.packages("fmsb") 19 | install.packages("palmerpenguins") 20 | install.packages("neuralnet") 21 | install.packages("kernlab") 22 | install.packages("ROCR") 23 | install.packages("pROC") -------------------------------------------------------------------------------- /src/lectures/101_L_Introduction.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 101" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/101_L_Introduction.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/102_L_CoreConcepts.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 102" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/102_L_CoreConcepts.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/103_L_Tidyverse.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 103" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/103_L_Tidyverse.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/111_L_DataTypes.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 111" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/111_L_DataTypes.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/112_L_ControlStructures.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 112" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/112_L_ControlStructures.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/113_L_Functions.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 113" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/113_L_Functions.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/201_L_DataFrames.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 201" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/201_L_DataFrames.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/202_L_SelectionFiltering.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 202" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/202_L_SelectionFiltering.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/203_L_DataManipulation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 203" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/203_L_DataManipulation.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/211_L_DataJoin.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 211" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/211_L_DataJoin.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/212_L_TidyData.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 212" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/212_L_TidyData.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/213_L_ReadWrite.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 213" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | highlight: tango 11 | --- 12 | 13 | ```{r child = 'contents/213_L_ReadWrite.Rmd'} 14 | ``` 15 | -------------------------------------------------------------------------------- /src/lectures/221_L_Reproducibility.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 221" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/221_L_Reproducibility.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/222_L_RMarkdown.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 222" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/222_L_RMarkdown.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/223_L_Git.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 223" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/223_L_Git.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/301_L_DataVisualisation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 301" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/301_L_DataVisualisation.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/302_L_DescriptiveStats.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 302" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/302_L_DescriptiveStats.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/303_L_ExploringAssumptions.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 303" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/303_L_ExploringAssumptions.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/311_L_ComparingMeans.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 311" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/311_L_ComparingMeans.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/312_L_Correlation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 312" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/312_L_Correlation.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/313_L_DataTransformations.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 313" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/313_L_DataTransformations.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/321_L_Regression.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 321" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/321_L_Regression.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/322_L_RegressionMultiple.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 322" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/322_L_RegressionMultiple.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/323_L_RegressionComparing.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 323" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/323_L_RegressionComparing.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/401_L_MachineLearningIntro.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 401" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/401_L_MachineLearningIntro.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/402_L_NeuralNetworks.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 402" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/402_L_NeuralNetworks.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/403_L_SupportVectorMachines.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 403" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/403_L_SupportVectorMachines.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/411_L_PrincipalComponents.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 411" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/411_L_PrincipalComponents.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/412_L_ClusteringCentroid.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 412" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/412_L_ClusteringCentroid.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/413_L_ClusteringHierarchicalDensity.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture 413" 3 | author: "granolarr by Dr Stefano De Sabbata
School of Geography, Geology, and the Env.
University of Leicester
github.com/sdesabbata/granolarr
s.desabbata@le.ac.uk | @maps4thought
text and code licensed under GNU GPL v3.0" 4 | date: "`r Sys.Date()`" 5 | output: 6 | ioslides_presentation: 7 | template: ../utils/IOSlides/UoL_Template.html 8 | logo: ../../src/utils/IOSlides/uol_logo.png 9 | css: ../utils/RMarkdown/rmarkdown_classes.css 10 | --- 11 | 12 | ```{r child = 'contents/413_L_ClusteringHierarchicalDensity.Rmd'} 13 | ``` 14 | -------------------------------------------------------------------------------- /src/lectures/contents/101_L_Introduction.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Introduction to R 10 | 11 | 12 | 13 | ## About this module 14 | 15 | This module will provide you with the fundamental skills in 16 | 17 | - basic programming in R 18 | - data wrangling 19 | - data analysis 20 | - reproducibility 21 | 22 | basis for 23 | 24 | - *Geospatial Data Analysis* 25 | - *Geospatial Databases and Information Retrieval* 26 | 27 | 28 | 29 | ## R programming language 30 | 31 | One of the most widely used programming languages and an effective tool for *(geospatial)* data science 32 | 33 | :::::: {.cols data-latex=""} 34 | 35 | ::: {.col data-latex="{0.5\textwidth}"} 36 | 37 | - data wrangling 38 | - statistical analysis 39 | - machine learning 40 | - data visualisation and maps 41 | - processing spatial data 42 | - geographic information analysis 43 | 44 | ::: 45 | 46 | ::: {.col data-latex="{0.5\textwidth}"} 47 | 48 | ```{r, echo=FALSE, message=FALSE, warning=FALSE, results='hide', fig.height = 4, fig.width = 4} 49 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "tmp")), FALSE) 50 | 51 | if (!dir.exists(file.path("./tmp", "E06000016"))) { 52 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "e06000016.zip"), exdir = "tmp") 53 | } 54 | 55 | library(sp) 56 | library(rgdal) 57 | leic_2011OAC <- readOGR("tmp/E06000016/E06000016_Leicester.shp") 58 | 59 | library(tmap) 60 | tm_shape(leic_2011OAC) + 61 | tm_polygons( 62 | "supgrpname", 63 | legend.show = FALSE, 64 | border.alpha = 0) + 65 | tm_layout( 66 | bg.color = "#EBE3E1", 67 | frame = FALSE) + 68 | tm_credits( 69 | "Source: CDRC 2011 OAC Geodata Pack by the ESRC Consumer\nDataResearch Centre; Contains National Statistics data Crown\ncopyright and database right 2015; Contains Ordnance Survey\ndata Crown copyright and database right 2015", 70 | size = 0.3, 71 | position = c("right", "bottom") 72 | ) 73 | 74 | unlink("tmp/E06000016", recursive = TRUE) 75 | if(length(list.files(path = "./tmp", include.dirs = TRUE)) == 0){ 76 | unlink("tmp", recursive = TRUE) 77 | } 78 | ``` 79 | 80 | ::: 81 | 82 | :::::: 83 | 84 | 85 | 86 | ## Schedule 87 | 88 | The lectures and practical sessions have been designed to follow the schedule below 89 | 90 | 91 | 92 | :::::: {.cols data-latex=""} 93 | 94 | ::: {.col data-latex="{0.5\textwidth}"} 95 | 96 | - **1 R coding** 97 | - 100 Introduction 98 | - 110 R programming 99 | - **2 Data wrangling** 100 | - 200 Selection and manipulation 101 | - 210 Table operations 102 | - 220 Reproducibility 103 | 104 | ::: 105 | 106 | ::: {.col data-latex="{0.5\textwidth}"} 107 | 108 | - **3 Data analysis** 109 | - 300 Exploratory data analysis 110 | - 310 Comparing data 111 | - 320 Regression models 112 | - **4 Machine learning** 113 | - 400 Unsupervised 114 | - 410 Supervised 115 | 116 | ::: 117 | :::::: 118 | 119 | 120 | 121 | ## Reference books 122 | 123 |
124 | Suggested reading 125 | 126 | - *Programming Skills for Data Science: Start Writing Code to Wrangle, Analyze, and Visualize Data with R* by Michael Freeman and Joel Ross, Addison-Wesley, 2019. See book [webpage](https://www.pearson.com/us/higher-education/program/Freeman-Programming-Skills-for-Data-Science-Start-Writing-Code-to-Wrangle-Analyze-and-Visualize-Data-with-R/PGM2047488.html) and [repository](https://programming-for-data-science.github.io/). 127 | - *R for Data Science* by Garrett Grolemund and Hadley Wickham, O'Reilly Media, 2016. See [online book](https://r4ds.had.co.nz/). 128 | - *Discovering Statistics Using R* by Andy Field, Jeremy Miles and Zoë Field, SAGE Publications Ltd, 2012. See book [webpage](https://www.discoveringstatistics.com/books/discovering-statistics-using-r/). 129 | - *Machine Learning with R: Expert techniques for predictive modeling* by Brett Lantz, Packt Publishing, 2019. See book [webpage](https://subscription.packtpub.com/book/big_data_and_business_intelligence/9781788295864). 130 | 131 | Further reading 132 | 133 | - *The Art of R Programming: A Tour of Statistical Software Design* by Norman Matloff, No Starch Press, 2011. See book [webpage](https://nostarch.com/artofr.htm) 134 | - *An Introduction to R for Spatial Analysis and Mapping* by Chris Brunsdon and Lex Comber, Sage, 2015. See book [webpage](https://uk.sagepub.com/en-gb/eur/an-introduction-to-r-for-spatial-analysis-and-mapping/book241031) 135 | - *Geocomputation with R* by Robin Lovelace, Jakub Nowosad, Jannes Muenchow, CRC Press, 2019. See [online book](https://bookdown.org/robinlovelace/geocompr/). 136 |
137 | 138 | 139 | ## R 140 | 141 | Created in 1992 by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand 142 | 143 | - Free, open-source implementation of *S* 144 | - statistical programming language 145 | - Bell Labs 146 | 147 |
148 | 149 | - Functional programming language 150 | - Supports (and commonly used as) procedural (i.e., imperative) programming 151 | - Object-oriented 152 | - Interpreted (not compiled) 153 | 154 | 155 | 156 | ## Interpreting values 157 | 158 | When values and operations are inputted in the *Console*, the interpreter returns the results of its interpretation of the expression 159 | 160 | ```{r, echo=TRUE} 161 | 2 162 | "String value" 163 | # comments are ignored 164 | ``` 165 | 166 | 167 | 168 | ## Basic types 169 | 170 | R provides three core data types 171 | 172 | - numeric 173 | - both integer and real numbers 174 | - character 175 | - i.e., text, also called *strings* 176 | - logical 177 | - `TRUE` or `FALSE` 178 | 179 | 180 | ## Numeric operators 181 | 182 | R provides a series of basic numeric operators 183 | 184 |
185 | 186 | |Operator|Meaning |Example |Output | 187 | |--------|----------------|---------|-----------| 188 | |+ |Plus |`5 + 2` |`r 5 + 2` | 189 | |- |Minus |`5 - 2` |`r 5 - 2` | 190 | |`*` |Product |`5 * 2` |`r 5 * 2` | 191 | |/ |Division |`5 / 2` |`r 5 / 2` | 192 | |%/% |Integer division|`5 %/% 2`|`r 5 %/% 2`| 193 | |%% |Module |`5 %% 2` |`r 5 %% 2` | 194 | |^ |Power |`5^2` |`r 5^2` | 195 | 196 |
197 |
198 | 199 | ```{r, echo=TRUE} 200 | 5 + 2 201 | ``` 202 | 203 | 204 | 205 | ## Logical operators 206 | 207 | 208 | R provides a series of basic logical operators to test 209 | 210 |
211 | 212 | |Operator|Meaning |Example |Output | 213 | |--------|------------------|------------------|--------------------| 214 | |== |Equal |`5 == 2` |`r 5 == 2` | 215 | |!= |Not equal |`5 != 2` |`r 5 != 2` | 216 | |> (>=) |Greater (or equal)|`5 > 2` |`r 5 > 2` | 217 | |< (<=) |Less (or equal) |`5 <= 2` |`r 5 <= 2` | 218 | |! |Not |`!TRUE` |`r !TRUE` | 219 | |& |And |`TRUE & FALSE` |`r TRUE & FALSE` | 220 | |\| |Or |`TRUE | FALSE` |`r TRUE | FALSE` | 221 | 222 |
223 |
224 | 225 | ```{r, echo=TRUE} 226 | 5 >= 2 227 | ``` 228 | 229 | 230 | 231 | ## Summary 232 | 233 | An introduction to R 234 | 235 | - Basic types 236 | - Basic operators 237 | 238 | **Next**: Core concepts 239 | 240 | - Variables 241 | - Functions 242 | - Libraries 243 | 244 | ```{r cleanup, include=FALSE} 245 | rm(list = ls()) 246 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/102_L_CoreConcepts.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Core concepts 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: An introduction to R 16 | 17 | - Basic types 18 | - Basic operators 19 | 20 | **Now**: Core concepts 21 | 22 | - Variables 23 | - Functions 24 | - Libraries 25 | 26 | 27 | 28 | ## Variables 29 | 30 | Variables **store data** and can be defined 31 | 32 | - using an *identifier* (e.g., `a_variable`) 33 | - on the left of an *assignment operator* `<-` 34 | - followed by the object to be linked to the identifier 35 | - such as a *value* (e.g., `1`) 36 | 37 | ```{r, echo=TRUE} 38 | a_variable <- 1 39 | ``` 40 | 41 | The value of the variable can be invoked by simply specifying the **identifier**. 42 | 43 | ```{r, echo=TRUE} 44 | a_variable 45 | ``` 46 | 47 | 48 | 49 | ## Algorithms and functions 50 | 51 | *An* **algorithm** *or effective procedure is a mechanical rule, or automatic method, or programme for performing some mathematical operation* (Cutland, 1980). 52 | 53 | A **program** is a specific set of instructions that implement an abstract algorithm. 54 | 55 | The definition of an algorithm (and thus a program) can consist of one or more **function**s 56 | 57 | - set of instructions that preform a task 58 | - possibly using an input, possibly returning an output value 59 | 60 | Programming languages usually provide pre-defined functions that implement common algorithms (e.g., to find the square root of a number or to calculate a linear regression) 61 | 62 | 63 | 64 | ## Functions 65 | 66 | Functions execute complex operations and can be invoked 67 | 68 | - specifying the *function name* 69 | - the *arguments* (input values) between simple brackets 70 | - each *argument* corresponds to a *parameter* 71 | - sometimes the *parameter* name must be specified 72 | 73 | ```{r, echo=TRUE} 74 | sqrt(2) 75 | round(1.414214, digits = 2) 76 | ``` 77 | 78 | 79 | 80 | ## Functions and variables 81 | 82 | - functions can be used on the right side of `<-` 83 | - variables and functions can be used as *arguments* 84 | 85 | ```{r, echo=TRUE} 86 | sqrt_of_two <- sqrt(2) 87 | sqrt_of_two 88 | round(sqrt_of_two, digits = 2) 89 | round(sqrt(2), digits = 2) 90 | ``` 91 | 92 | 93 | 94 | ## Naming 95 | 96 | When creating an identifier for a variable or function 97 | 98 | - R is a **case sensitive** language 99 | - UPPER and lower case are not the same 100 | - `a_variable` is different from `a_VARIABLE` 101 | - names can include 102 | - alphanumeric symbols 103 | - `.` and `_` 104 | - names must start with 105 | - a letter 106 | 107 | 108 | 109 | ## Libraries 110 | 111 | Once a number of related, reusable functions are created 112 | 113 | - they can be collected and stored in **libraries** (a.k.a. *packages*) 114 | - `install.packages` is a function that can be used to install libraries (i.e., downloads it on your computer) 115 | - `library` is a function that *loads* a library (i.e., makes it available to a script) 116 | 117 | Libraries can be of any size and complexity, e.g.: 118 | 119 | - `base`: base R functions, including the `sqrt` function above 120 | - `rgdal`: implementation of the [GDAL (Geospatial Data Abstraction Library)](https://gdal.org/) functionalities 121 | 122 | 123 | ## stringr 124 | 125 | R provides some basic functions to manipulate strings, but the `stringr` library provides a more consistent and well-defined set 126 | 127 | ```{r, echo=TRUE} 128 | library(stringr) 129 | 130 | str_length("Leicester") 131 | str_detect("Leicester", "e") 132 | str_replace_all("Leicester", "e", "x") 133 | ``` 134 | 135 | 136 | 137 | 138 | ## Summary 139 | 140 | Core concepts 141 | 142 | - Variables 143 | - Functions 144 | - Libraries 145 | 146 | **Next**: Tidyverse 147 | 148 | - Tidyverse libraries 149 | - *pipe* operator 150 | 151 | ```{r cleanup, include=FALSE} 152 | rm(list = ls()) 153 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/103_L_Tidyverse.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Tidyverse 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Core concepts 16 | 17 | - Variables 18 | - Functions 19 | - Libraries 20 | 21 | **Now**: Tidyverse 22 | 23 | - Tidyverse libraries 24 | - *pipe* operator 25 | 26 | 27 | ## Tidyverse 28 | 29 | The [Tidyverse](https://www.tidyverse.org/) was introduced by statistician [Hadley Wickham](https://t.co/DWqWlxbOKK?amp=1), Chief Scientist at [RStudio](https://rstudio.com/) (worth following him on [twitter](https://twitter.com/hadleywickham)). 30 | 31 | *"The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures."* ([Tidyverse homepage](https://www.tidyverse.org/)). 32 | 33 | **Core libraries** 34 | 35 | :::::: {.cols data-latex=""} 36 | 37 | ::: {.col data-latex="{0.5\textwidth}" style="width: 50%"} 38 | 39 | 40 | - [`tibble`](https://tibble.tidyverse.org/) 41 | - [`tidyr`](https://tidyr.tidyverse.org/) 42 | - [`stringr`](https://stringr.tidyverse.org/) 43 | - [`dplyr`](https://dplyr.tidyverse.org/) 44 | 45 | 46 | ::: 47 | 48 | ::: {.col data-latex="{0.5\textwidth}" style="width: 50%"} 49 | 50 | - [`readr`](https://readr.tidyverse.org/) 51 | - [`ggplot2`](https://ggplot2.tidyverse.org/) 52 | - [`purrr`](https://purrr.tidyverse.org/) 53 | - [`forcats`](https://forcats.tidyverse.org/) 54 | 55 | ::: 56 | :::::: 57 | 58 | Also, imports [`magrittr`](https://magrittr.tidyverse.org/), which plays an important role. 59 | 60 | ## Tidyverse core libraries 61 | 62 | The meta-library [Tidyverse](https://www.tidyverse.org/) includes: 63 | 64 | - **[`tibble`](https://tibble.tidyverse.org/)** is a modern re-imagining of the data frame, keeping what time has proven to be effective, and throwing out what it has not. Tibbles are data.frames that are lazy and surly: they do less and complain more forcing you to confront problems earlier, typically leading to cleaner, more expressive code. 65 | - **[`tidyr`](https://tidyr.tidyverse.org/)** provides a set of functions that help you get to tidy data. Tidy data is data with a consistent form: in brief, every variable goes in a column, and every column is a variable. 66 | - **[`stringr`](https://stringr.tidyverse.org/)** provides a cohesive set of functions designed to make working with strings as easy as possible. It is built on top of stringi, which uses the ICU C library to provide fast, correct implementations of common string manipulations. 67 | 68 | 69 | ## Tidyverse core libraries 70 | 71 | The meta-library [Tidyverse](https://www.tidyverse.org/) includes: 72 | 73 | - **[`dplyr`](https://dplyr.tidyverse.org/)** provides a grammar of data manipulation, providing a consistent set of verbs that solve the most common data manipulation challenges. 74 | - **[`readr`](https://readr.tidyverse.org/)** provides a fast and friendly way to read rectangular data (like csv, tsv, and fwf). It is designed to flexibly parse many types of data found in the wild, while still cleanly failing when data unexpectedly changes. 75 | - **[`ggplot2`](https://ggplot2.tidyverse.org/)** is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details. 76 | 77 | 78 | 79 | ## Tidyverse core libraries 80 | 81 | The meta-library [Tidyverse](https://www.tidyverse.org/) contains the following libraries: 82 | 83 | - **[`purrr`](https://purrr.tidyverse.org/)** enhances R’s functional programming (FP) toolkit by providing a complete and consistent set of tools for working with functions and vectors. Once you master the basic concepts, purrr allows you to replace many for loops with code that is easier to write and more expressive. 84 | - **[`forcats`](https://forcats.tidyverse.org/)** provides a suite of useful tools that solve common problems with factors. R uses factors to handle categorical variables, variables that have a fixed and known set of possible values. 85 | 86 | 87 | 88 | ## The pipe operator 89 | 90 | The [Tidyverse](https://www.tidyverse.org/) (via [`magrittr`](https://magrittr.tidyverse.org/)) also provide a clean and effective way of combining multiple manipulation steps 91 | 92 | The pipe operator `%>%` 93 | 94 | - takes the result from one function 95 | - and passes it to the next function 96 | - as the **first argument** 97 | - that doesn't need to be included in the code anymore 98 | 99 | 100 | 101 | ## Pipe example 102 |
103 | ![Pipe operator example and diagram](images/PipeOperator.png){width=100%} 104 |
105 | 106 | 107 | ## Pipe example 108 | 109 | The two codes below are equivalent 110 | 111 | - the first simply invokes the functions 112 | - the second uses the pipe operator `%>%` 113 | 114 | ```{r, echo=TRUE} 115 | round(sqrt(2), digits = 2) 116 | ``` 117 | 118 | ```{r, echo=TRUE, message=FALSE, warning=FALSE} 119 | library(tidyverse) 120 | 121 | sqrt(2) %>% 122 | round(digits = 2) 123 | ``` 124 | 125 | 126 | 127 | ## Coding style 128 | 129 | A *coding style* is a way of writing the code, including 130 | 131 | - how variable and functions are named 132 | - lower case and `_` 133 | - how spaces are used in the code 134 | - which libraries are used 135 | 136 | ```{r, echo=TRUE, eval=FALSE} 137 | # Bad 138 | X<-round(sqrt(2),2) 139 | 140 | #Good 141 | sqrt_of_two <- sqrt(2) %>% 142 | round(digits = 2) 143 | ``` 144 | 145 | Study the [Tidyverse Style Guid](http://style.tidyverse.org/) and use it consistently! 146 | 147 | 148 | ## Summary 149 | 150 | Tidyverse 151 | 152 | - Tidyverse libraries 153 | - *pipe* operator 154 | - Coding style 155 | 156 | **Next**: Practical session 157 | 158 | - The R programming language 159 | - Interpreting values 160 | - Variables 161 | - Basic types 162 | - Tidyverse 163 | - Coding style 164 | 165 | ```{r cleanup, include=FALSE} 166 | rm(list = ls()) 167 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/112_L_ControlStructures.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Control structures 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Data types 16 | 17 | - Vectors 18 | - Factors 19 | - Matrices and arrays 20 | - Lists 21 | 22 | **Now**: Control structures 23 | 24 | - Conditional statements 25 | - Loops 26 | 27 | 28 | 29 | ## If 30 | 31 | Format: **if** (*condition*) *statement* 32 | 33 | - *condition*: expression returning a logic value (`TRUE` or `FALSE`) 34 | - *statement*: any valid R statement 35 | - *statement* only executed if *condition* is `TRUE` 36 | 37 | 38 | ```{r, echo=TRUE} 39 | a_value <- -7 40 | if (a_value < 0) cat("Negative") 41 | a_value <- 8 42 | if (a_value < 0) cat("Negative") 43 | ``` 44 | 45 | 46 | ## Else 47 | Format: **if** (*condition*) *statement1* **else** *statement2* 48 | 49 | - *condition*: expression returning a logic value (`TRUE` or `FALSE`) 50 | - *statement1* and *statement2*: any valid R statements 51 | - *statement1* executed if *condition* is `TRUE` 52 | - *statement2* executed if *condition* is `FALSE` 53 | 54 | 55 | ```{r, echo=TRUE} 56 | a_value <- -7 57 | if (a_value < 0) cat("Negative") else cat("Positive") 58 | a_value <- 8 59 | if (a_value < 0) cat("Negative") else cat("Positive") 60 | ``` 61 | 62 | 70 | 71 | 72 | ## Code blocks 73 | 74 | **Code blocks** allow to encapsulate **several** statements in a single group 75 | 76 | - `{` and `}` contain code blocks 77 | - the statements are execute together 78 | 79 | ```{r, echo=TRUE} 80 | first_value <- 8 81 | second_value <- 5 82 | if (first_value > second_value) { 83 | cat("First is greater than second\n") 84 | difference <- first_value - second_value 85 | cat("Their difference is ", difference) 86 | } 87 | ``` 88 | 89 | 90 | 91 | ## Loops 92 | Loops are a fundamental component of (procedural) programming. 93 | 94 | 95 | There are two main types of loops: 96 | 97 | - **conditional** loops are executed as long as a defined condition holds true 98 | - construct `while` 99 | - construct `repeat` 100 | - **deterministic** loops are executed a pre-determined number of times 101 | - construct `for` 102 | 103 | 104 | ## While 105 | 106 | The *while* construct can be defined using the `while` reserved word, followed by the conditional statement between simple brackets, and a code block. The instructions in the code block are re-executed as long as the result of the evaluation of the conditional statement is `TRUE`. 107 | 108 | ```{r, echo=TRUE} 109 | current_value <- 0 110 | 111 | while (current_value < 3) { 112 | cat("Current value is", current_value, "\n") 113 | current_value <- current_value + 1 114 | } 115 | ``` 116 | 117 | 139 | 140 | ## For 141 | 142 | The *for* construct can be defined using the `for` reserved word, followed by the definition of an **iterator**. The iterator is a variable which is temporarily assigned with the current element of a vector, as the construct iterates through all elements of the vector. This definition is followed by a code block, whose instructions are re-executed once for each element of the vector. 143 | 144 | ```{r, echo=TRUE} 145 | cities <- c("Derby", "Leicester", "Lincoln", "Nottingham") 146 | for (city in cities) { 147 | cat("Do you live in", city, "?\n") 148 | } 149 | ``` 150 | 151 | 152 | ## For 153 | 154 | It is common practice to create a vector of integers on the spot in order to execute a certain sequence of steps a pre-defined number of times. 155 | 156 | ```{r, echo=TRUE} 157 | for (i in 1:3) { 158 | cat("This is exectuion number", i, ":\n") 159 | cat(" See you later!\n") 160 | } 161 | ``` 162 | 163 | 164 | ## Loops with conditional statements 165 | 166 | ```{r, echo=TRUE} 167 | 3:0 168 | #Example: countdown! 169 | for (i in 3:0) { 170 | if (i == 0) { 171 | cat("Go!\n") 172 | } else { 173 | cat(i, "\n") 174 | } 175 | } 176 | ``` 177 | 178 | 179 | 180 | ## Summary 181 | 182 | Control structures 183 | 184 | - Conditional statements 185 | - Loops 186 | 187 | **Next**: Functions 188 | 189 | - Defining functions 190 | - Scope of a variable 191 | 192 | ```{r cleanup, include=FALSE} 193 | rm(list = ls()) 194 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/113_L_Functions.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Functions 10 | 11 | 12 | ## Summary 13 | 14 | **Prev**:Control structures 15 | 16 | - Conditional statements 17 | - Loops 18 | 19 | **Now**: Functions 20 | 21 | - Defining functions 22 | - Scope of a variable 23 | 24 | 25 | 26 | ## Defining functions 27 | 28 | A function can be defined 29 | 30 | - using an **identifier** (e.g., `add_one`) 31 | - on the left of an **assignment operator** `<-` 32 | - followed by the corpus of the function 33 | 34 | ```{r, echo=TRUE} 35 | add_one <- function (input_value) { 36 | output_value <- input_value + 1 37 | output_value 38 | } 39 | ``` 40 | 41 | ## Defining functions 42 | 43 | The corpus 44 | 45 | - starts with the reserved word `function` 46 | - followed by the **parameter(s)** (e.g., `input_value`) between simple brackets 47 | - and the instruction(s) to be executed in a code block 48 | - the value of the last statement is returned as output 49 | 50 | ```{r, echo=TRUE} 51 | add_one <- function (input_value) { 52 | output_value <- input_value + 1 53 | output_value 54 | } 55 | ``` 56 | 57 | 58 | ## Defining functions 59 | 60 | After being defined 61 | 62 | - a function can be invoked by specifying 63 | - the **identifier** 64 | - the necessary **parameter(s)** 65 | 66 | ```{r, echo=TRUE} 67 | add_one(3) 68 | add_one(1024) 69 | ``` 70 | 71 | 72 | ## More parameters 73 | 74 | - A function can be defined as having two or more **parameters** 75 | - by specifying more than one parameter name (separated by **commas**) in the function definition 76 | - A function always take as input as many values as the number of parameters specified in the definition 77 | - otherwise an error is generated 78 | 79 | ```{r, echo=TRUE} 80 | area_rectangle <- function (hight, width) { 81 | area <- hight * width 82 | area 83 | } 84 | 85 | area_rectangle(3, 2) 86 | ``` 87 | 88 | 89 | ## Functions and control structures 90 | 91 | Functions can contain both loops and conditional statements 92 | 93 | ```{r, echo=TRUE} 94 | factorial <- function (input_value) { 95 | result <- 1 96 | for (i in 1:input_value) { 97 | cat("current:", result, " | i:", i, "\n") 98 | result <- result * i 99 | } 100 | result 101 | } 102 | factorial(3) 103 | ``` 104 | 105 | 106 | 124 | 125 | 126 | 127 | ## Scope 128 | 129 | The **scope of a variable** is the part of code in which the variable is ``visible'' 130 | 131 | In R, variables have a **hierarchical** scope: 132 | 133 | - a variable defined in a script can be used referred to from within a definition of a function in the same script 134 | - a variable defined within a definition of a function will **not** be referable from outside the definition 135 | - scope does **not** apply to `if` or loop constructs 136 | 137 | 138 | ## Example 139 | 140 | In the case below 141 | 142 | - `x_value` is **global** to the function `times_x` 143 | - `new_value` and `input_value` are **local** to the function `times_x` 144 | - referring to `new_value` or `input_value` from outside the definition of `times_x` would result in an error 145 | 146 | ```{r, echo=TRUE} 147 | x_value <- 10 148 | times_x <- function (input_value) { 149 | new_value <- input_value * x_value 150 | new_value 151 | } 152 | times_x(2) 153 | ``` 154 | 157 | 158 | 159 | 205 | 206 | 207 | ## Summary 208 | 209 | Functions 210 | 211 | - Defining functions 212 | - Scope of a variable 213 | 214 | **Next**: Practical session 215 | 216 | - Conditional statements 217 | - Loops 218 | - While 219 | - For 220 | - Functions 221 | - Loading functions from scripts 222 | - Debugging 223 | 224 | ```{r cleanup, include=FALSE} 225 | rm(list = ls()) 226 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/201_L_DataFrames.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Data Frames 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: R programming 16 | 17 | - 111 Lecture: Data types 18 | - 112 Lecture: Control structures 19 | - 113 Lecture: Functions 20 | - 114 Practical session 21 | 22 | **Now**: Data Frames 23 | 24 | - Data Frames 25 | - Tibbles 26 | 27 | 28 | ## Lists and named lists 29 | 30 | **List** 31 | 32 | - can contain elements of different types 33 | - whereas elements of vectors are all of the same type 34 | - in **named lists**, each element has a name 35 | - elements can be selected using the operator `$` 36 | 37 | ```{r, echo=TRUE} 38 | employee <- list(employee_name = "Stef", start_year = 2015) 39 | employee[[1]] 40 | employee$employee_name 41 | ``` 42 | 43 | 44 | 45 | ## Data Frames 46 | 47 | A **data frame** is equivalent to a *named list* where all elements are *vectors of the same length*. 48 | 49 | ```{r, echo=TRUE} 50 | employees <- data.frame( 51 | EmployeeName = c("Maria", "Pete", "Sarah"), 52 | Age = c(47, 34, 32), 53 | Role = c("Professor", "Researcher", "Researcher")) 54 | employees 55 | ``` 56 | 57 | Data frames are the most common way to represent tabular data in R. Matrices and lists can be converted to data frames. 58 | 59 | 62 | 63 | ## Selection 64 | 65 | Selection is similar to vectors and lists. 66 | 67 | ```{r, echo=TRUE} 68 | employees[1, 1] # value selection 69 | employees[1, ] # row selection 70 | employees[, 1] # column selection 71 | ``` 72 | 73 | 74 | ## Selection 75 | 76 | Selection is similar to vectors and lists. 77 | 78 | ```{r, echo=TRUE} 79 | employees$EmployeeName # column selection, as for named lists 80 | employees$EmployeeName[1] 81 | ``` 82 | 83 | 84 | 85 | ## Table manipulation 86 | 87 | - Values can be assigned to cells 88 | - using any selection method 89 | - and the assignment operator `<-` 90 | - New columns can be defined 91 | - assigning a vector to a new name 92 | 93 | ```{r, echo=TRUE} 94 | employees$Age[3] <- 33 95 | employees$Place <- c("Leicester", "Leicester","Leicester") 96 | employees 97 | ``` 98 | 99 | 100 | 101 | ## Column processing 102 | 103 | Operations can be performed on columns as they where vectors 104 | 105 | ```{r, echo=TRUE} 106 | 10 - c(1, 2, 3) 107 | ``` 108 | 109 | ```{r, echo=TRUE} 110 | # Use Sys.Date to retrieve the current year 111 | current_year <- as.integer(format(Sys.Date(), "%Y")) 112 | 113 | # Calculate employee year of birth 114 | employees$Year_of_birth <- current_year - employees$Age 115 | employees 116 | ``` 117 | 118 | 119 | 120 | ## tibble 121 | 122 | A [tibble](https://tibble.tidyverse.org/) is a modern reimagining of the data.frame within `tidyverse` 123 | 124 | - they do less 125 | - don’t change column names or types 126 | - don’t do partial matching 127 | - complain more 128 | - e.g. when referring to a column that does not exist 129 | 130 | That forces you to confront problems earlier, typically leading to cleaner, more expressive code. 131 | 132 | 133 | 134 | ## Summary 135 | 136 | Data Frames 137 | 138 | - Data Frames 139 | - Tibbles 140 | 141 | **Next**: Data selection and filtering 142 | 143 | - dplyr 144 | - dplyr::select 145 | - dplyr::filter 146 | 147 | ```{r cleanup, include=FALSE} 148 | rm(list = ls()) 149 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/202_L_SelectionFiltering.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Selection and filtering 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Data Frames 16 | 17 | - Data Frames 18 | - Tibbles 19 | 20 | **Now**: Data selection and filtering 21 | 22 | - dplyr 23 | - dplyr::select 24 | - dplyr::filter 25 | 26 | 27 | 28 | ## dplyr 29 | 30 | The `dplyr` (pronounced *dee-ply-er*) library is part of `tidyverse` and it offers a grammar for data manipulation 31 | 32 | - `select`: select specific columns 33 | - `filter`: select specific rows 34 | - `arrange`: arrange rows in a particular order 35 | - `summarise`: calculate aggregated values (e.g., mean, max, etc) 36 | - `group_by`: group data based on common column values 37 | - `mutate`: add columns 38 | - `join`: merge tables (`tibbles` or `data.frames`) 39 | 40 | ```{r, echo=TRUE, message=FALSE, warning=FALSE} 41 | library(tidyverse) 42 | ``` 43 | 44 | 45 | 46 | ## Example dataset 47 | 48 | The library `nycflights13` contains a dataset storing data about all the flights departed from New York City in 2013 49 | 54 | ```{r, echo=TRUE, eval=FALSE, message=FALSE, warning=FALSE} 55 | library(nycflights13) 56 | 57 | nycflights13::flights 58 | ``` 59 | ```{r, echo=FALSE} 60 | library(nycflights13) 61 | 62 | nycflights13::flights %>% 63 | print(n= 3, width = 70) 64 | ``` 65 | 66 | 67 | 68 | ## Selecting table columns 69 | 70 | Columns of **data frames** and **tibbles** can be selected 71 | 72 | - specifying the column index 73 | 74 | ```{r, echo=TRUE, eval=FALSE} 75 | nycflights13::flights[, c(13, 14)] 76 | ``` 77 | 78 | - specifying the column name 79 | 80 | ```{r, echo=TRUE, eval=FALSE} 81 | nycflights13::flights[, c("origin", "dest")] 82 | ``` 83 | ```{r, echo=FALSE} 84 | nycflights13::flights[, c("origin", "dest")] %>% 85 | print(n = 3) 86 | ``` 87 | 88 | 89 | 90 | ## dplyr::select 91 | 92 | `select` can be used to specify which columns to retain 93 | 94 | ```{r, echo=TRUE, eval=FALSE} 95 | nycflights13::flights %>% 96 | dplyr::select( 97 | origin, dest, dep_delay, arr_delay, year:day 98 | ) 99 | ``` 100 | ```{r, echo=FALSE} 101 | nycflights13::flights %>% 102 | dplyr::select( 103 | origin, dest, dep_delay, arr_delay, year:day 104 | ) %>% 105 | print(n = 5) 106 | ``` 107 | 108 | 109 | ## dplyr::select 110 | 111 | ... or whichones to drop, using - in front of the column name 112 | 113 | ```{r, echo=TRUE, eval=FALSE} 114 | nycflights13::flights %>% 115 | dplyr::select(origin, dest, dep_delay, arr_delay, year:day) %>% 116 | dplyr::select(-arr_delay) 117 | ``` 118 | ```{r, echo=FALSE} 119 | nycflights13::flights %>% 120 | dplyr::select( 121 | origin, dest, dep_delay, arr_delay, year:day 122 | ) %>% 123 | dplyr::select( 124 | -arr_delay 125 | ) %>% 126 | print(n = 3) 127 | ``` 128 | 129 | 130 | ## Logical filtering 131 | 132 | Conditional statements can be used to filter a vector 133 | 134 | - i.e. to retain only certain values 135 | - where the specified value is `TRUE` 136 | 137 | ```{r, echo=TRUE} 138 | a_numeric_vector <- -3:3 139 | a_numeric_vector 140 | a_numeric_vector[c(FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE)] 141 | ``` 142 | 143 | 144 | 145 | ## Conditional filtering 146 | 147 | As a conditional expression results in a logic vector... 148 | 149 | ```{r, echo=TRUE} 150 | a_numeric_vector > 0 151 | ``` 152 | 153 |
154 | ... conditional expressions can be used for filtering 155 | 156 | ```{r, echo=TRUE} 157 | a_numeric_vector[a_numeric_vector > 0] 158 | ``` 159 | 160 | 161 | 162 | ## Filtering data frames 163 | 164 | The same approach can be applied to **data frames** and **tibbles** 165 | 166 | ```{r, echo=TRUE, eval=FALSE} 167 | nycflights13::flights$month 168 | ``` 169 | ```{r, echo=FALSE} 170 | capture.output(nycflights13::flights$month)[1] %>% str_trunc(52) %>% cat() 171 | ``` 172 | 173 | ```{r, echo=TRUE, eval=FALSE} 174 | nycflights13::flights$month == 11 175 | ``` 176 | ```{r, echo=FALSE} 177 | capture.output(nycflights13::flights$month == 11)[1] %>% str_trunc(52) %>% cat() 178 | ``` 179 | 180 | ```{r, echo=TRUE, eval=FALSE} 181 | nycflights13::flights[nycflights13::flights$month == 11, ] 182 | ``` 183 | ```{r, echo=FALSE} 184 | nycflights13::flights[nycflights13::flights$month == 11, ] %>% 185 | print(n = 1, width = 52) 186 | ``` 187 | 188 | 189 | 190 | ## dplyr::filter 191 | 192 | ```{r, echo=TRUE, eval=FALSE} 193 | nycflights13::flights %>% 194 | # Flights in November 195 | dplyr::filter(month == 11) 196 | ``` 197 | ```{r, echo=FALSE} 198 | nycflights13::flights %>% 199 | dplyr::filter(month == 11) %>% 200 | print(n = 3, width = 52) 201 | ``` 202 | 203 | 204 | 205 | 206 | ## Select and filter 207 | 208 | ```{r, echo=TRUE, eval=FALSE} 209 | nycflights13::flights %>% 210 | # Select the columns you need 211 | dplyr::select(origin, dest, dep_delay, arr_delay, year:day) %>% 212 | # Drop arr_delay... because you don't need it after all 213 | dplyr::select(-arr_delay) %>% 214 | # Filter in only November flights 215 | dplyr::filter(month == 11) 216 | ``` 217 | ```{r, echo=FALSE} 218 | nycflights13::flights %>% 219 | dplyr::select(origin, dest, dep_delay, arr_delay, year:day) %>% 220 | dplyr::select(-arr_delay) %>% 221 | dplyr::filter(month == 11) %>% 222 | print(n = 3, width = 52) 223 | ``` 224 | 225 | 226 | 227 | ## Summary 228 | 229 | Data selection and filtering 230 | 231 | - dplyr 232 | - dplyr::select 233 | - dplyr::filter 234 | 235 | **Next**: Data manipulation 236 | 237 | - dplyr::arrange 238 | - dplyr::summarise 239 | - dplyr::group_by 240 | - dplyr::mutate 241 | 242 | 243 | 244 | ```{r cleanup, include=FALSE} 245 | rm(list = ls()) 246 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/203_L_DataManipulation.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Data manipulation 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Data selection and filtering 16 | 17 | - dplyr 18 | - dplyr::select 19 | - dplyr::filter 20 | 21 | **Now**: Data manipulation 22 | 23 | - dplyr::arrange 24 | - dplyr::summarise 25 | - dplyr::group_by 26 | - dplyr::mutate 27 | 28 | 29 | ## Example 30 | 31 | ```{r, echo=TRUE, eval=FALSE} 32 | library(tidyverse) 33 | library(nycflights13) 34 | 35 | nov_dep_delays <- 36 | nycflights13::flights %>% 37 | dplyr::select(origin, dest, dep_delay, year:day) %>% 38 | dplyr::filter(month == 11) 39 | 40 | nov_dep_delays 41 | ``` 42 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 43 | library(tidyverse) 44 | library(nycflights13) 45 | 46 | nov_dep_delays <- 47 | nycflights13::flights %>% 48 | dplyr::select(origin, dest, dep_delay, year:day) %>% 49 | dplyr::filter(month == 11) 50 | 51 | nov_dep_delays %>% print(n = 3) 52 | ``` 53 | 54 | 55 | 56 | ## dplyr::arrange 57 | 58 | Arranges rows in a particular order 59 | 60 | - descending orders specified by using `-` (minus symbol) 61 | 62 | ```{r, echo=TRUE, eval=FALSE} 63 | nov_dep_delays %>% 64 | dplyr::arrange( 65 | # Ascending destination name 66 | dest, 67 | # Descending delay 68 | -dep_delay 69 | ) 70 | ``` 71 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 72 | nov_dep_delays %>% 73 | dplyr::arrange( 74 | dest, # Ascending destination name 75 | -dep_delay # Descending delay 76 | ) %>% 77 | print(n = 2) 78 | ``` 79 | 80 | 81 | 82 | ## dplyr::summarise 83 | 84 | Calculates aggregated values 85 | 86 | - e.g., using functions such as mean, max, etc. 87 | 88 | ```{r, echo=TRUE} 89 | nov_dep_delays %>% 90 | # Need to filter out rows where delay is NA 91 | dplyr::filter(!is.na(dep_delay)) %>% 92 | # Create two aggregated columns 93 | dplyr::summarise( 94 | avg_dep_delay = mean(dep_delay), 95 | tot_dep_delay = sum(dep_delay) 96 | ) 97 | ``` 98 | 99 | 100 | 101 | ## dplyr::group_by 102 | 103 | Groups rows based on common values for specified column(s) 104 | 105 | - combined with `summarise`, aggregated values per group 106 | 107 | ```{r, echo=TRUE, eval=FALSE} 108 | nov_dep_delays %>% 109 | # First group by same destination 110 | dplyr::group_by(dest) %>% 111 | # Then calculate aggregated value 112 | dplyr::filter(!is.na(dep_delay)) %>% 113 | dplyr::summarise(tot_dep_delay = sum(dep_delay)) 114 | ``` 115 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 116 | nov_dep_delays %>% 117 | # First group by same destination 118 | dplyr::group_by(dest) %>% 119 | # Need to filter out rows where delay is NA 120 | dplyr::filter(!is.na(dep_delay)) %>% 121 | # Then calculate aggregated value 122 | dplyr::summarise( 123 | tot_dep_delay = sum(dep_delay) 124 | ) %>% 125 | print(n = 2) 126 | ``` 127 | 128 | 129 | 130 | ## dplyr::tally and dplyr::count 131 | 132 | - `dplyr::tally` short-hand for `summarise` with `n` 133 | - number of rows 134 | - `dplyr::count`short-hand for `group_by` and `tally` 135 | - number of rows per group 136 | 137 | 138 | ```{r, echo=TRUE, eval=FALSE} 139 | nov_dep_delays %>% 140 | # Count flights by same destination 141 | dplyr::count(dest) 142 | ``` 143 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 144 | nov_dep_delays %>% 145 | # Count flights by same destination 146 | dplyr::count(dest) %>% 147 | print(n = 3) 148 | ``` 149 | 150 | 151 | ## dplyr::mutate 152 | 153 | Calculate values for new columns based on current columns 154 | 155 | ```{r, echo=TRUE, eval=FALSE} 156 | nov_dep_delays %>% 157 | dplyr::mutate( 158 | # Combine origin and destination into one column 159 | orig_dest = str_c(origin, dest, sep = "->"), 160 | # Departure delay in days (rather than minutes) 161 | delay_days = ((dep_delay / 60) /24) 162 | ) 163 | ``` 164 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 165 | nov_dep_delays %>% 166 | dplyr::mutate( 167 | orig_dest = str_c(origin, dest, sep = "->"), 168 | delay_days = ((dep_delay / 60) /24) 169 | ) %>% 170 | print(n = 3) 171 | ``` 172 | 173 | 174 | ## Full pipe example 175 | 176 | ```{r, echo=TRUE, eval=FALSE} 177 | nycflights13::flights %>% 178 | dplyr::select( 179 | origin, dest, dep_delay, arr_delay, 180 | year:day 181 | ) %>% 182 | dplyr::select(-arr_delay) %>% 183 | dplyr::filter(month == 11) %>% 184 | dplyr::filter(!is.na(dep_delay)) %>% 185 | dplyr::arrange(dest, -dep_delay) %>% 186 | dplyr::group_by(dest) %>% 187 | dplyr::summarise( 188 | tot_dep_delay = sum(dep_delay) 189 | ) %>% 190 | dplyr::mutate( 191 | tot_dep_delay_days = ((tot_dep_delay / 60) /24) 192 | ) 193 | ``` 194 | 195 | 196 | 197 | ## Full pipe example 198 | 199 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 200 | nycflights13::flights %>% 201 | dplyr::select( 202 | origin, dest, dep_delay, arr_delay, 203 | year:day 204 | ) %>% 205 | dplyr::select(-arr_delay) %>% 206 | dplyr::filter(month == 11) %>% 207 | dplyr::filter(!is.na(dep_delay)) %>% 208 | dplyr::arrange(dest, -dep_delay) %>% 209 | dplyr::group_by(dest) %>% 210 | dplyr::summarise( 211 | tot_dep_delay = sum(dep_delay) 212 | ) %>% 213 | dplyr::mutate( 214 | tot_dep_delay_days = ((tot_dep_delay / 60) /24) 215 | ) 216 | ``` 217 | 218 | 219 | 220 | ## Summary 221 | 222 | Data manipulation 223 | 224 | - dplyr::arrange 225 | - dplyr::summarise 226 | - dplyr::group_by 227 | - dplyr::mutate 228 | 229 | **Next**: Practical session 230 | 231 | - Creating R projects 232 | - Creating R scripts 233 | - Data wrangling script 234 | 235 | ```{r cleanup, include=FALSE} 236 | rm(list = ls()) 237 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/211_L_DataJoin.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Join operations 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Selection and manipulation 16 | 17 | - Data frames and tibbles 18 | - Data selection and filtering 19 | - Data manipulation 20 | 21 | **Now**: Join operations 22 | 23 | - Joining data 24 | - dplyr join functions 25 | 26 | 27 | ## Example 28 | 29 | ```{r, echo=TRUE} 30 | cities <- data.frame( 31 | city_name = c("Barcelona", "London", "Rome", "Los Angeles"), 32 | country_name = c("Spain", "UK", "Italy", "US"), 33 | city_pop_M = c(1.62, 8.98, 4.34, 3.99) 34 | ) 35 | 36 | cities_area <-data.frame( 37 | city_name = c("Barcelona", "London", "Rome", "Munich"), 38 | city_area_km2 = c(101, 1572, 496, 310) 39 | ) 40 | ``` 41 | 42 | ## Example 43 | 44 | ```{r, echo=FALSE} 45 | library(knitr) 46 | 47 | knitr::kable(cities) 48 | ``` 49 | 50 |
51 | 52 | ```{r, echo=FALSE} 53 | knitr::kable(cities_area) 54 | ``` 55 | 56 | 57 | 58 | 59 | 60 | ## Joining data 61 | 62 | Tables can be joined (or 'merged') 63 | 64 | - information from two tables can be combined 65 | - specifying **column(s) from two tables with common values** 66 | - usually one with a unique identifier of an entity 67 | - rows having the same value are joined 68 | - depending on parameters 69 | - a row from one table can be merged with multiple rows from the other table 70 | - rows with no matching values in the other table can be retained 71 | - `merge` base function or join functions in `dplyr` 72 | 73 | 74 | 75 | ## Join types 76 | 77 |
78 | ![](images/joins.png){width=75%} 79 | 80 |
81 | 82 | 83 | 84 | ## dplyr joins 85 | 86 | `dplyr` provides [a series of join verbs](https://dplyr.tidyverse.org/reference/join.html) 87 | 88 | - **Mutating joins** 89 | - `inner_join`: inner join 90 | - `left_join`: left join 91 | - `right_join`: right join 92 | - `full_join`: full join 93 | - **Nesting joins** 94 | - `nest_join`: all rows columns from left table, plus a column of tibbles with matching from right 95 | - **Filtering joins** (keep only columns from left) 96 | - `semi_join`: , rows from left where match with right 97 | - `anti_join`: rows from left where no match with right 98 | 99 | 100 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 101 | library(tidyverse) 102 | ``` 103 | 104 | 105 | ## dplyr::full_join 106 | 107 | - `full_join` combines all the available data 108 | 109 | ```{r, echo=TRUE, eval=FALSE} 110 | dplyr::full_join( 111 | # first argument, left table 112 | # second argument, right table 113 | cities, cities_area, 114 | # specify which column to be matched 115 | by = c("city_name" = "city_name") 116 | ) 117 | ``` 118 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 119 | cities %>% 120 | dplyr::full_join(cities_area) %>% 121 | knitr::kable() 122 | ``` 123 | 124 | 125 | ## Pipes and shorthands 126 | 127 | When using (all) join verbs in `dplyr` 128 | 129 | ```{r, echo=TRUE, eval=FALSE} 130 | # using pipe, left table is "coming down the pipe" 131 | cities %>% 132 | dplyr::full_join(cities_area, by = c("city_name" = "city_name")) 133 | 134 | # if no columns specified, columns with the same name are matched 135 | cities %>% 136 | dplyr::full_join(cities_area) 137 | ``` 138 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 139 | cities %>% 140 | dplyr::full_join(cities_area) %>% 141 | knitr::kable() 142 | ``` 143 | 144 | 145 | 146 | ## dplyr::left_join 147 | 148 | - keeps all the data from the **left** table 149 | - first argument or *"coming down the pipe"* 150 | - rows from the right table without a match are dropped 151 | - second argument (or first when using *pipes*) 152 | 153 | ```{r, echo=TRUE, eval=FALSE} 154 | cities %>% 155 | dplyr::left_join(cities_area) 156 | ``` 157 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 158 | cities %>% 159 | dplyr::left_join(cities_area) %>% 160 | knitr::kable() 161 | ``` 162 | 163 | 164 | 165 | ## dplyr::right_join 166 | 167 | - keeps all the data from the **right** table 168 | - second argument (or first when using *pipes*) 169 | - rows from the left table without a match are dropped 170 | - first argument or *"coming down the pipe"* 171 | 172 | ```{r, echo=TRUE, eval=FALSE} 173 | cities %>% 174 | dplyr::right_join(cities_area) 175 | ``` 176 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 177 | cities %>% 178 | dplyr::right_join(cities_area) %>% 179 | knitr::kable() 180 | ``` 181 | 182 | 183 | 184 | 185 | ## dplyr::inner_join 186 | 187 | - keeps only rows that have a match in **both** tables 188 | - rows without a match either way are dropped 189 | 190 | ```{r, echo=TRUE, eval=FALSE} 191 | cities %>% 192 | dplyr::inner_join(cities_area) 193 | ``` 194 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 195 | cities %>% 196 | dplyr::inner_join(cities_area) %>% 197 | knitr::kable() 198 | ``` 199 | 200 | 201 | 202 | ## dplyr::semi_join and anti_join 203 | 204 | ```{r, echo=TRUE, eval=FALSE} 205 | cities %>% 206 | dplyr::semi_join(cities_area) 207 | ``` 208 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 209 | cities %>% 210 | dplyr::semi_join(cities_area) %>% 211 | knitr::kable() 212 | ``` 213 | 214 |
215 | 216 | ```{r, echo=TRUE, eval=FALSE} 217 | cities %>% 218 | dplyr::anti_join(cities_area) 219 | ``` 220 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 221 | cities %>% 222 | dplyr::anti_join(cities_area) %>% 223 | knitr::kable() 224 | ``` 225 | 226 | 227 | 228 | ## Summary 229 | 230 | Join operations 231 | 232 | - Joining data 233 | - dplyr join functions 234 | 235 | **Next**: Tidy-up your data 236 | 237 | - Wide and long data 238 | - Re-shape data 239 | - Handle missing values 240 | 241 | ```{r cleanup, include=FALSE} 242 | rm(list = ls()) 243 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/221_L_Reproducibility.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Reproducibility 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Table operations 16 | 17 | - 211 Join operations 18 | - 212 Data pivot 19 | - 213 Read and write data 20 | - 214 Practical session 21 | 22 | **Now**: Reproduciblity 23 | 24 | - Reproduciblity and software engineering 25 | - Reproduciblity in GIScience 26 | - Guidelines 27 | 28 | 29 | ## Reproduciblity 30 | 31 | In quantitative research, an analysis or project are considered to be **reproducible** if: 32 | 33 | - *"the data and code used to make a finding are available and they are sufficient for an independent researcher to recreate the finding."* [Christopher Gandrud, *Reproducible Research with R and R Studio*](https://www.crcpress.com/Reproducible-Research-with-R-and-R-Studio/Gandrud/p/book/9781498715379) 34 | 35 | That is becoming more and more important in science: 36 | 37 | - as programming and scripting are becoming integral in most disciplines 38 | - as the amount of data increases 39 | 40 | 41 | 42 | ## Why? 43 | 44 | In **scientific research**: 45 | 46 | - verificability of claims through replication 47 | - incremental work, avoid duplication 48 | 49 | For your **working practice**: 50 | 51 | - better working practices 52 | - coding 53 | - project structure 54 | - versioning 55 | - better teamwork 56 | - higher impact (not just results, but code, data, etc.) 57 | 58 | 59 | 60 | ## Reproducibility and software engineering 61 | 62 | Core aspects of **software engineering** are: 63 | 64 | - project design 65 | - software **readibility** 66 | - testing 67 | - **versioning** 68 | 69 | As programming becomes integral to research, similar necessities arise among scientists and data analysts. 70 | 71 | 72 | 73 | ## Reproducibility and "big data" 74 | 75 | There has been a lot of discussions about **"big data"**... 76 | 77 | - volume, velocity, variety, ... 78 | 79 | Beyond the hype of the moment, as the **amount** and **complexity** of data increases 80 | 81 | - the time required to replicate an analysis using point-and-click software becomes unsustainable 82 | - room for error increases 83 | 84 | Workflow management software (e.g., ArcGIS ModelBuilder) is one answer, reproducible data analysis based on script languages like R is another. 85 | 86 | 87 | 88 | ## Reproducibility in GIScience 89 | 90 | [Singleton *et al.*](https://www.tandfonline.com/doi/abs/10.1080/13658816.2015.1137579) have discussed the issue of reproducibility in GIScience, identifying the following best practices: 91 | 92 | 1. Data should be accessible within the public domain and available to researchers. 93 | 2. Software used should have open code and be scrutable. 94 | 3. Workflows should be public and link data, software, methods of analysis and presentation with discursive narrative 95 | 4. The peer review process and academic publishing should require submission of a workflow model and ideally open archiving of those materials necessary for 96 | replication. 97 | 5. Where full reproducibility is not possible (commercial software or sensitive data) aim to adopt aspects attainable within circumstances 98 | 99 | 100 | 101 | ## Document everything 102 | 103 | In order to be reproducible, every step of your project should be documented in detail 104 | 105 | - data gathering 106 | - data analysis 107 | - results presentation 108 | 109 | Well documented R scripts are an excellent way to document your project. 110 | 111 | 112 | 113 | ## Document well 114 | 115 | Create code that can be **easily understood** by someone outside your project, including yourself in six-month time! 116 | 117 | - use a style guide (e.g. [tidyverse](http://style.tidyverse.org/)) consistently 118 | - also add a **comment** before any line that could be ambiguous or particularly difficult or important 119 | - add a **comment** before each code block, describing what the code does 120 | - add a **comment** at the beginning of a file, including 121 | - date 122 | - contributors 123 | - other files the current file depends on 124 | - materials, sources and other references 125 | 126 | 127 | 128 | ## Workflow 129 | 130 | Relationships between files in a project are not simple: 131 | 132 | - in which order are file executed? 133 | - when to copy files from one folder to another, and where? 134 | 135 | A common solution is using **make files** 136 | 137 | - commonly written in *bash* on Linux systems 138 | - they can be written in R, using commands like 139 | - *source* to execute R scripts 140 | - *system* to interact with the operative system 141 | 142 | 143 | 144 | ## granolarr Mark.R 145 | 146 | Section of the [*granolarr*](https://sdesabbata.github.io/granolarr/) project make file [Make.R](https://github.com/sdesabbata/granolarr/blob/master/Make.R) that generates the current slides for the lecture session 221 147 | 148 | ```{} 149 | cat("\n\n>>> Rendering 221_L_Reproducibility.Rmd <<<\n\n") 150 | rmarkdown::render( 151 | paste0( 152 | Sys.getenv("GRANOLARR_HOME"), 153 | "/src/lectures/221_L_Reproducibility.Rmd" 154 | ), 155 | quiet = TRUE, 156 | output_dir = paste0( 157 | Sys.getenv("GRANOLARR_HOME"), 158 | "/docs/lectures/html" 159 | ) 160 | ) 161 | ``` 162 | 163 | 164 | ## Future-proof formats 165 | 166 | Complex formats (e.g., .docx, .xlsx, .shp, ArcGIS .mxd) 167 | 168 | - can become obsolete 169 | - are not always portable 170 | - usually require proprietary software 171 | 172 | Use the simplest format to **future-proof** your analysis.
**Text files** are the most versatile 173 | 174 | - data: .txt, .csv, .tsv 175 | - analysis: R scrpts, python scripts 176 | - write-up: LaTeX, Markdown, HTML 177 | 178 | 179 | 180 | ## Store and share 181 | 182 | Reproducible data analysis is particularly important when working in teams, to share and communicate your work. 183 | 184 | - [Dropbox](https://www.dropbox.com) 185 | - good option to work in teams, initially free 186 | - no versioning, branches 187 | - [Git](https://git-scm.com) 188 | - free and opensource control system 189 | - great to work in teams and share your work publically 190 | - can be more difficult at first 191 | - [GitHub](https://github.com) public repositories are free, private ones are not 192 | - [GitLab](https://about.gitlab.com/) offers free private repositories 193 | 194 | 195 | 196 | ## Summary 197 | 198 | Reproduciblity 199 | 200 | - Reproduciblity and software engineering 201 | - Reproduciblity in GIScience 202 | - Guidelines 203 | 204 | **Next**: RMarkdown 205 | 206 | - Markdown 207 | - RMarkdown 208 | 209 | ```{r cleanup, include=FALSE} 210 | rm(list = ls()) 211 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/222_L_RMarkdown.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # RMarkdown 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Reproduciblity 16 | 17 | - Reproduciblity and software engineering 18 | - Reproduciblity in GIScience 19 | - Guidelines 20 | 21 | **Now**: RMarkdown 22 | 23 | - Markdown 24 | - RMarkdown 25 | 26 | 27 | 28 | ## Markdown 29 | 30 | **Markdown** is a simple markup language 31 | 32 | - allows to mark-up plain text 33 | - to specify more complex features (such as *italics text*) 34 | - using a very simple [syntax](https://daringfireball.net/projects/markdown/syntax) 35 | 36 | Markdown can be used in conjunction with numerous tools 37 | 38 | - to produce HTML pages 39 | - or even more complex formats (such as PDF) 40 | 41 | These slides are written in Markdown 42 | 43 | 44 | 45 | ## Markdown example code 46 | 47 | ``` 48 | ### This is a third level heading 49 | 50 | Text can be specified as *italic* or **bold** 51 | 52 | - and list can be created 53 | - very simply 54 | 55 | 1. also numbered lists 56 | 1. [add a link like this](http://le.ac.uk) 57 | 58 | |Tables |Can |Be | 59 | |-------|------------|---------| 60 | |a bit |complicated |at first | 61 | |but |it gets |easier | 62 | ``` 63 | 64 | 65 | 66 | ## Markdown example output 67 | 68 | ### This is a third level heading 69 | 70 | Text can be specified as *italic* or **bold** 71 | 72 | - and list can be created 73 | - very simply 74 | 75 | 1. also numbered lists 76 | 1. [add a link like this](http://le.ac.uk) 77 | 78 | |Tables |Can |Be | 79 | |-------|------------|---------| 80 | |a bit |complicated |at first | 81 | |but |it gets |easier | 82 | 83 | 84 | 85 | ## RMarkdown 86 | 87 | The [rmarkdown](https://rmarkdown.rstudio.com/docs/) library and its [RStudio plug-in](https://rmarkdown.rstudio.com/) 88 | 89 | - provide functionalities to *compile* scripts containing 90 | - **Markdown** text 91 | - rendered to documents (e.g., *.pdf* and *.doc*) 92 | - chunks of **R** code (other supported, e.g., Python, SQL) 93 | - included in output document 94 | - interpreted 95 | - results included in output document 96 | 97 | ```` 98 | `r ''````{r, echo=TRUE} 99 | # Example of R chunck 100 | sqrt(2) 101 | `r ''```` 102 | ```` 103 | 104 | 105 | ## RMarkdown example 106 | 107 | Content of an RMarkdown file: `First_example.Rmd` 108 | 109 | ```` 110 | This is an **RMarkdown** document. The *code chunk* below: 111 | 112 | - loads the necessary libraries 113 | - loads the flights from New York City in 2013 114 | - presents a few columns from the first row 115 | 116 | `r ''````{r, echo=TRUE, message=FALSE, warning=FALSE} 117 | library(tidyverse) 118 | library(nycflights13) 119 | 120 | nycflights13::flights %>% 121 | dplyr::select(year:day, origin, dest, flight) %>% 122 | dplyr::slice_head(1) %>% 123 | knitr::kable() 124 | `r ''```` 125 | ```` 126 | 127 | 128 | ## RMarkdown example 129 | 130 | This is an **RMarkdown** document. The *code chunk* below: 131 | 132 | - loads the necessary libraries 133 | - loads the flights from New York City in 2013 134 | - presents a few columns from the first row 135 | 136 | ```{r, echo=TRUE, message=FALSE, warning=FALSE} 137 | library(tidyverse) 138 | library(nycflights13) 139 | 140 | nycflights13::flights %>% 141 | dplyr::select(year:day, origin, dest, flight) %>% 142 | dplyr::slice_head(1) %>% 143 | knitr::kable() 144 | ``` 145 | 146 | 147 | ## The Definitive Guide 148 | 149 | :::::: {.cols data-latex=""} 150 | ::: {.col style="width: 60%;" data-latex="{0.5\textwidth}"} 151 | 152 | Markdown is a rather simple for a markup language, but still fairly complex, especially when used in combination with R. 153 | 154 | For an complete guide to RMarkdown, please see: 155 | 156 | [R Markdown:
The Definitive Guide](https://bookdown.org/yihui/rmarkdown/) 157 | 158 | by
159 | Yihui Xie,
160 | J. J. Allaire,
161 | Garrett Grolemund. 162 | 163 | ::: 164 | ::: {.col style="width: 50%; text-align: right;" data-latex="{0.5\textwidth}"} 165 | 166 | ![](https://bookdown.org/yihui/rmarkdown/images/cover.png) 167 | 168 | ::: 169 | :::::: 170 | 171 | ## Summary 172 | 173 | RMarkdown 174 | 175 | - Markdown 176 | - RMarkdown 177 | 178 | **Next**: Git and Docker 179 | 180 | - Git operations 181 | - Git and RStudio 182 | - Docker 183 | 184 | ```{r cleanup, include=FALSE} 185 | rm(list = ls()) 186 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/223_L_Git.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Git 10 | 11 | 12 | ## Recap 13 | 14 | RMarkdown 15 | 16 | - Markdown 17 | - RMarkdown 18 | 19 | **Next**: Git and Docker 20 | 21 | - Git operations 22 | - Git and RStudio 23 | - Docker 24 | 25 | 26 | 27 | ## What's git? 28 | 29 | **Git** is a free and opensource version control system 30 | 31 | - commonly used through a server 32 | - where a master copy of a project is kept 33 | - can also be used locally 34 | - allows storing versions of a project 35 | - syncronisation 36 | - consistency 37 | - history 38 | - multiple branches 39 | 40 | 41 | 42 | ## How git works 43 | 44 | A series of snapshots 45 | 46 | - each commit is a snapshot of all files 47 | - if no change to a file, link to previous commit 48 | - all history stored locally 49 | 50 |
51 | ![](images/git_snapshots.png){width=80%} 52 | 53 |
54 | 55 | by Scott Chacon and Ben Straub, licensed under CC BY-NC-SA 3.0 56 | 57 |
58 | 59 | 60 | 61 | ## Three stages 62 | 63 | When working with a git repository 64 | 65 | - first checkout the latest version 66 | - select the edits to stage 67 | - commit what has been staged in a permanent snapshot 68 | 69 |
70 | ![](images/git_three_stages.png){width=60%} 71 | 72 |
73 | 74 | by Scott Chacon and Ben Straub, licensed under CC BY-NC-SA 3.0 75 | 76 |
77 | 78 | 79 | ## Basic git commands 80 | 81 | - `git clone` 82 | - copy a repository from a server 83 | - `git fetch` 84 | - get the latest version from a branch 85 | - `git pull` 86 | - incorporate changes from a remote repository 87 | - `git add` 88 | - stage new files 89 | - `git commit` 90 | - create a commit 91 | - `git push` 92 | - upload commits to a remote repository 93 | 94 | 95 | 96 | ## Git and RStudio 97 | 98 | Git can be used 99 | 100 | - from the system terminal or shell, using the `git` command 101 | - dedicated apps such as [GitHub Desktop](https://desktop.github.com/) 102 | - RStudio git plug-in (top-right panel, `Git` tab) 103 | 104 | All approaches allow to 105 | 106 | - clone R projects from repositories 107 | - stage and commit changes 108 | - push to remote copy 109 | - pull changes from remote copy 110 | 111 | 112 | 113 | ## What's Docker? 114 | 115 | 116 | :::::: {.cols data-latex=""} 117 | ::: {.col data-latex="{0.5\textwidth}"} 118 | 119 | 120 | Docker allows to encapsulate and share computational environments 121 | 122 | - First released in 2013 123 | - Similar to virtual machines 124 | - simulates a guest operative system 125 | - within a host operative system 126 | - Lightweight 127 | - doesn't simulate an entire system 128 | - only the *"user space"* is simulated 129 | 130 | ::: 131 | ::: {.col style="width: 40%;" data-latex="{0.5\textwidth}"} 132 | 133 | ![](images/DockerDiagram_VM.png) 134 |

135 | ![](images/DockerDiagram_Docker.png) 136 | 137 | ::: 138 | :::::: 139 | 140 | 141 | ## Virtual machines 142 | 143 | :::::: {.cols data-latex=""} 144 | ::: {.col style="width: 100%;" data-latex="{0.5\textwidth}"} 145 | 146 | Virtual machines software (e.g., VMWare) simulate a computer on top of your operative system 147 | 148 | - allows **virtual machine** to access physical resources (e.g., disk, keyboard) of a **host** 149 | - allows to run full operative systems 150 | - e.g., run a full Windows virtual machine on a Mac host 151 | - have been around since the 1970s 152 | - can be *heavy* to run 153 | 154 | ::: 155 | ::: {.col style="width: 80%; text-align: right;" data-latex="{0.5\textwidth}"} 156 | ![](images/DockerDiagram_VM.png) 157 | ::: 158 | :::::: 159 | 160 | 161 | 162 | ## Docker containers 163 | 164 | :::::: {.cols data-latex=""} 165 | ::: {.col style="width: 100%;" data-latex="{0.5\textwidth}"} 166 | 167 | Docker runs *containers* 168 | 169 | - developed for flexible deployment of (web) services 170 | - compartimentalised 171 | - lightweight 172 | - (frequently) transient 173 | - **kernel** is not simulated 174 | - kernels are the bulk of operative systems 175 | - containers share host's kernel 176 | - can also share binaries and libraries 177 | 178 | ::: 179 | ::: {.col style="width: 80%; text-align: right;" data-latex="{0.5\textwidth}"} 180 | ![](images/DockerDiagram_Docker.png) 181 | ::: 182 | 183 | :::::: 184 | 185 | 186 | 187 | ## Docker and reproducibility 188 | 189 | Why are dockers useful for reproducibility? 190 | 191 | One of the key issues of reproducing a study is replicating the computational environment used 192 | 193 | - e.g., all the libraries in their correct version 194 | 195 | Creating a Docker image (from which a container is instantiated) 196 | 197 | - defined using a [*Dokerfile*](https://docs.docker.com/engine/reference/builder/) 198 | - requires to list a full system configuration 199 | - version of programming language, libraries, etc 200 | - once created / defined 201 | - other researchers or developers can run your script **in the exact same computational environment** 202 | 203 | 204 | ## granolarr Dockerfile 205 | 206 | ```{} 207 | # Base image https://hub.docker.com/r/rocker/ml 208 | FROM rocker/geospatial:4.0.2 209 | 210 | # create an R user 211 | ENV USER rstudio 212 | 213 | ## Install additional required R libraries 214 | COPY ./DockerConfig/Requirements.R /tmp/Requirements.R 215 | RUN Rscript /tmp/Requirements.R 216 | 217 | ## Install additional required TeX libraries 218 | RUN tlmgr install amsmath 219 | RUN tlmgr install latex-amsmath-dev 220 | RUN tlmgr install iftex 221 | RUN tlmgr install euenc 222 | RUN tlmgr install fontspec 223 | ``` 224 | 225 | [... continues] 226 | 227 | 228 | 229 | ## Summary 230 | 231 | Git and Docker 232 | 233 | - Git operations 234 | - Git and RStudio 235 | - Docker 236 | 237 | **Next**: Practical 238 | 239 | - Reproducibile data analysis 240 | - RMarkdown 241 | - Git 242 | 243 | ```{r cleanup, include=FALSE} 244 | rm(list = ls()) 245 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/401_L_MachineLearningIntro.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 8 | 9 | # Machine Learning 10 | 11 | 12 | 13 | ## Recap 14 | 15 | **Prev**: Regression models 16 | 17 | - 321 Lecture Simple regression 18 | - 322 Lecture Assessing regression assumptions 19 | - 323 Lecture Multiple regression 20 | - 324 Practical session 21 | 22 | **Now**: Machine Learning 23 | 24 | - What's Machine Learning? 25 | - Types 26 | - Limitations 27 | 28 | 29 | 30 | ## Definition 31 | 32 |
33 | *"The field of machine learning is concerned with the question of how to construct computer programs that automatically improve with experience."* 34 | 35 | Mitchell, T. (1997). Machine Learning. McGraw Hill. 36 | 37 | 38 | ## Origines 39 | 40 | 41 | - **Computer Science**: 42 | - how to manually program computers to solve tasks 43 | 44 | - **Statistics**: 45 | - what conclusions can be inferred from data 46 | 47 | - **Machine Learning**: 48 | - intersection of **computer science** and **statistics** 49 | - how to get computers to **program themselves** from experience plus some initial structure 50 | - effective data capture, store, index, retrieve and merge 51 | - computational tractability 52 | 53 | 54 | Mitchell, T.M., 2006. The discipline of machine learning (Vol. 9). Pittsburgh, PA: Carnegie Mellon University, School of Computer Science, Machine Learning Department. 55 | 56 | 57 | 58 | ## Types of machine learning 59 | 60 | Machine learning approaches are divided into two main types 61 | 62 | - **Supervised** 63 | - training of a *"predictive"* model from data 64 | - one (or more) attribute of the dataset is used to "predict" another attribute 65 | - e.g., classification 66 | 67 | - **Unsupervised** 68 | - discovery of *descriptive* patterns in data 69 | - commonly used in data mining 70 | - e.g., clustering 71 | 72 | 73 | 74 | ## Supervised 75 | 76 | :::::: {.cols data-latex=""} 77 | 78 | ::: {.col data-latex="{0.5\textwidth}"} 79 | 80 | - Training dataset 81 | - input attribute(s) 82 | - attribute to predict 83 | - Testing dataset 84 | - input attribute(s) 85 | - attribute to predict 86 | - Type of learning model 87 | - Evaluation function 88 | - evaluates difference between prediction and output in testing data 89 | 90 | ::: 91 | 92 | ::: {.col data-latex="{0.5\textwidth}"} 93 | 94 |
95 | ![](images/MnistExamples.png){width=90%} 96 | 97 |
98 | 99 | by Josef Steppan
100 | via Wikimedia Commons,
101 | CC-BY-SA-4.0 102 |
103 |
104 | 105 | ::: 106 | :::::: 107 | 108 | 109 | 110 | ## Unsupervised 111 | 112 | :::::: {.cols data-latex=""} 113 | 114 | ::: {.col data-latex="{0.5\textwidth}"} 115 | 116 | - Dataset 117 | - input attribute(s) to explore 118 | - Type of model for the learning process 119 | - most approaches are iterative 120 | - e.g., hierarchical clustering 121 | - Evaluation function 122 | - evaluates the quality of the pattern under consideration during one iteration 123 | 124 | ::: 125 | 126 | ::: {.col data-latex="{0.5\textwidth}"} 127 | 128 |
129 | ![](images/DBSCAN-Gaussian-data.png){width=90%} 130 | 131 |
132 | 133 | by Chire
134 | via Wikimedia Commons,
135 | CC-BY-SA-3.0 136 |
137 |
138 | 139 | ::: 140 | :::::: 141 | 142 | 143 | ## Semi-supervised learning 144 | 145 | Supervised learning requires *"labelled data"* 146 | 147 | - which can be expensive to acquire 148 | 149 | Semi-supervised learning 150 | 151 | - combines a small amount of labelled data with a larger un-labelled dataset 152 | - train on small labelled dataset 153 | - apply model to larger unlabled dataset generating *"pseudo-labels"* 154 | - re-train the model with all data (including *"pseudo-labels"*) 155 | - assumptions: continuity, cluster, and manifold (lower dimensionality) 156 | 157 | 158 | 159 | ## Reinforcement learning 160 | 161 | :::::: {.cols data-latex=""} 162 | 163 | ::: {.col data-latex="{0.5\textwidth}"} 164 | 165 | Based on the idea of training agents to learn how to 166 | 167 | - take actions 168 | - which affect 169 | - agent state 170 | - environment 171 | - to maximize reward 172 | - balancing 173 | - exploration (new paths/options) 174 | - exploitation (of current knowledge) 175 | 176 | ::: 177 | 178 | ::: {.col style="width: 70%; text-align: right;" data-latex="{0.5\textwidth}"} 179 | 180 |
181 | ![](images/Reinforcement_learning_diagram.svg.png) 182 | 183 | 184 |
185 | 186 | by Megajuice
187 | via Wikimedia Commons,
188 | CC0 1.0 189 |
190 |
191 | 192 | ::: 193 | :::::: 194 | 195 | 196 | 197 | 198 | ## Limits 199 | 200 | - Complexity 201 | - Creating a model requires hundreds of decisions 202 | - variable selection and normalisation 203 | - model, components, algorithm 204 | - hyper-parameters 205 | - evaluation 206 | - Black-boxes 207 | - recent developments in explainable artificial intelligence 208 | 209 | 210 | 211 | ## Overfitting 212 | 213 | :::::: {.cols data-latex=""} 214 | 215 | ::: {.col data-latex="{0.5\textwidth}"} 216 | 217 | - creating a model 218 | - perfect for the training data 219 | - but not generic enough 220 | - to be useful for prediction 221 | - An issue for machine learning 222 | - e.g., regression 223 | - n predictors can generate a line fitting the data exactly n cases 224 | - Occam's razor 225 | - one in ten rule 226 | - 10 cases per predictor 227 | 228 | 229 | ::: 230 | 231 | ::: {.col style="width: 70%; text-align: right;" data-latex="{0.5\textwidth}"} 232 | 233 |
234 | ![](images/Overfitted_Data.png) 235 | 236 |
237 | 238 | by Ghiles
ia Wikimedia Commons,
CC-BY-SA-4.0 239 |
240 |
241 | 242 | ::: 243 | :::::: 244 | 245 | 246 | ## Algorithmic bias 247 | 248 | Assumptions and training dataset quality still matter! 249 | 250 | - garbage in, garbage out 251 | 252 | Joy Buolamwini and Timnit Gebru's work on facial recognition 253 | 254 | - black women were 35% less likely to be recognised than white men. 255 | - Buolamwini, J. and Gebru, T., 2018. [Gender shades: Intersectional accuracy disparities in commercial gender classification](http://proceedings.mlr.press/v81/buolamwini18a.html?mod=article_inline). In Conference on fairness, accountability and transparency (pp. 77-91). 256 | - see also, [Facial Recognition Is Accurate, if You’re a White Guy](https://www.nytimes.com/2018/02/09/technology/facial-recognition-race-artificial-intelligence.html) by Steve Lohr (New York Times, Feb. 9, 2018) 257 | 258 | 259 | 260 | ## Summary 261 | 262 | Machine Learning 263 | 264 | - What's Machine Learning? 265 | - Types 266 | - Limitations 267 | 268 | **Next**: Artificial Neural Networks 269 | 270 | - Logistic regression 271 | - Artificial neural networks 272 | - Deep learning 273 | 274 | ```{r cleanup, include=FALSE} 275 | rm(list = ls()) 276 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/411_L_PrincipalComponents.Rmd: -------------------------------------------------------------------------------- 1 | ```{r setup, include=FALSE} 2 | knitr::opts_chunk$set(echo = FALSE) 3 | knitr::opts_knit$set(root.dir = Sys.getenv("GRANOLARR_HOME")) 4 | rm(list = ls()) 5 | ``` 6 | 7 | 21 | 22 | 23 | 24 | # Principal Component Analysis 25 | 26 | ## Recap 27 | 28 | **Prev**: Comparing data 29 | 30 | - 401 Lecture Introduction to Machine Learning 31 | - 402 Lecture Artificial Neural Networks 32 | - 403 Lecture Support vector machines 33 | - 404 Practical session 34 | 35 | **Now**: Principal Component Analysis 36 | 37 | - Principal components 38 | - `stats::prcomp` 39 | - Dimensionality reduction 40 | 41 | 42 | 43 | ```{r, echo=FALSE, message=FALSE, warning=FALSE,} 44 | library(tidyverse) 45 | library(magrittr) 46 | library(palmerpenguins) 47 | library(patchwork) 48 | ``` 49 | 50 | 51 | ## Principal components 52 | 53 | **Principal component** are 54 | 55 | - a set of directions orthogonal to each other 56 | - that best fit a set of data 57 | 58 | Can be interpreted as a *"re-projection"* of the data 59 | 60 | ```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 8, fig.height = 3} 61 | penguins_original_plot <- 62 | palmerpenguins::penguins %>% 63 | ggplot2::ggplot( 64 | aes( 65 | x = flipper_length_mm, 66 | y = body_mass_g 67 | ) 68 | ) + 69 | ggplot2::geom_point( 70 | aes( 71 | color = species, 72 | hape = species 73 | ), 74 | size = 2 75 | ) + 76 | ggplot2::scale_color_manual(values = c("darkorange","darkorchid","cyan4")) + 77 | ggplot2::theme_bw() + 78 | ggplot2::theme(legend.position = "none") 79 | 80 | penguins_fb_pca <- 81 | palmerpenguins::penguins %>% 82 | dplyr::select(flipper_length_mm, body_mass_g) %>% 83 | dplyr::filter(!is.na(flipper_length_mm)) %>% 84 | stats::prcomp(center = TRUE,scale. = TRUE) %$% 85 | x %>% 86 | as.data.frame() 87 | 88 | penguins_rotated_plot <- 89 | palmerpenguins::penguins %>% 90 | dplyr::filter(!is.na(flipper_length_mm)) %>% 91 | dplyr::bind_cols( 92 | penguins_fb_pca 93 | ) %>% 94 | dplyr::rename( 95 | `Direction 1` = PC1, 96 | `Direction 2` = PC2 97 | ) %>% 98 | ggplot2::ggplot( 99 | aes( 100 | x = `Direction 1`, 101 | y = `Direction 2` 102 | ) 103 | ) + 104 | ggplot2::geom_point( 105 | aes( 106 | color = species, 107 | hape = species 108 | ), 109 | size = 2 110 | ) + 111 | ggplot2::scale_color_manual(values = c("darkorange","darkorchid","cyan4")) + 112 | #ggplot2::coord_fixed(ratio = 1) + 113 | ylim(-2, 2) + 114 | ggplot2::theme_bw() + 115 | ggplot2::theme(legend.position = "none") 116 | 117 | (penguins_original_plot | penguins_rotated_plot) 118 | ``` 119 | 120 | 121 | ## Dimensionality reduction 122 | 123 | Alternatively, principal components can be interpreted as 124 | 125 | - **lower-dimensional** representation of the data 126 | 127 | Especially useful when working numerous variables 128 | 129 | - a limited number of principal components can be retained 130 | - most variance maintained 131 | - distance in data space approximated 132 | - high-dimensional data can be more easily plotted 133 | - commonly used as dimensionality reduction step 134 | - supervised learning models 135 | - linear regression 136 | - clustering 137 | 138 | 139 | ## stats::prcomp 140 | 141 | Principal component analysis on body mass, flipper length, and bill length and depth 142 | 143 |
144 | 145 | ```{r, echo=TRUE, message=FALSE, warning=FALSE} 146 | penguins_pca <- 147 | palmerpenguins::penguins %>% 148 | dplyr::select(bill_length_mm, bill_depth_mm, flipper_length_mm, body_mass_g) %>% 149 | # remove missing data 150 | dplyr::filter( 151 | !is.na(bill_length_mm) | !is.na(bill_depth_mm) | 152 | !is.na(flipper_length_mm) | !is.na(body_mass_g) 153 | ) %>% 154 | stats::prcomp(center = TRUE, scale. = TRUE) 155 | 156 | summary(penguins_pca) 157 | ``` 158 | 159 |
160 | 161 | The first component alone explains `r (summary(penguins_pca)$importance[3, 1] * 100) %>% round(digits = 2)`% of variance, and the first two together explain `r (summary(penguins_pca)$importance[3, 2] * 100) %>% round(digits = 2)`% of variance 162 | 163 | 164 | 165 | ## PCA results 166 | 167 |
168 | 169 | ```{r, echo=TRUE, message=FALSE, warning=FALSE} 170 | penguins_with_pca <- palmerpenguins::penguins %>% 171 | dplyr::filter(!is.na(bill_length_mm) | !is.na(bill_depth_mm) | 172 | !is.na(flipper_length_mm) | !is.na(body_mass_g)) %>% 173 | dplyr::bind_cols( 174 | penguins_pca %$% x %>% as.data.frame() 175 | ) 176 | ``` 177 | 178 |
179 | 180 | ```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 5, fig.height = 3.5} 181 | penguins_with_pca %>% 182 | ggplot2::ggplot( 183 | aes( 184 | x = PC1, 185 | y = PC2 186 | ) 187 | ) + 188 | ggplot2::geom_point( 189 | aes( 190 | color = species, 191 | hape = species 192 | ), 193 | size = 2 194 | ) + 195 | ggplot2::scale_color_manual(values = c("darkorange","darkorchid","cyan4")) + 196 | ggplot2::theme_bw() + 197 | ggplot2::theme(legend.position = "bottom") 198 | ``` 199 | 200 | 201 | ## Plotting PCA 202 | 203 | ```{r, echo=TRUE, message=FALSE, warning=FALSE, fig.width = 8, fig.height = 4} 204 | library(factoextra) 205 | 206 | penguins_pca %>% fviz_pca_biplot(label = "var") 207 | ``` 208 | 209 | 210 | ## Summary 211 | 212 | Principal Component Analysis 213 | 214 | - Principal components 215 | - `stats::prcomp` 216 | - Interpretation 217 | 218 | **Next**: Centroid-based clustering 219 | 220 | - K-means 221 | - Fuzzy c-means 222 | - Geodemographic classification 223 | 224 | 225 | ```{r cleanup, include=FALSE} 226 | rm(list = ls()) 227 | ``` -------------------------------------------------------------------------------- /src/lectures/contents/_bookdown.yml: -------------------------------------------------------------------------------- 1 | title: "Geographic data science reproducible teaching resource in R" 2 | author: "Stefano De Sabbata" 3 | date: "`r Sys.Date()`" 4 | new_session: yes -------------------------------------------------------------------------------- /src/lectures/contents/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lecture materials | granolarr" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | description: "Geographic data science reproducible teaching resource in R, Lecture materials" 6 | url: 'https://sdesabbata.github.io/granolarr/' 7 | github-repo: "sdesabbata/granolarr" 8 | site: bookdown::bookdown_site 9 | documentclass: book 10 | biblio-style: apalike 11 | output: 12 | bookdown::gitbook: 13 | config: 14 | toc: 15 | before: | 16 |
  • Lectures | granolarr
  • 17 | after: | 18 |
  • granolarr
  • 19 | search: yes 20 | download: 21 | - ["granolarr_lecture_materials.pdf", "PDF"] 22 | - ["granolarr_lecture_materials.epub", "EPUB"] 23 | bookdown::pdf_book: 24 | latex_engine: xelatex 25 | pandoc_args: ["--extract-media", "."] 26 | includes: 27 | in_header: ../../utils/RMarkdown/rmarkdown_classes.tex 28 | --- 29 | 30 | # Preface {-} 31 | 32 | *[Stefano De Sabbata](https://stefanodesabbata.com)* 33 | 34 | [This work](https://github.com/sdesabbata/GY7702) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html). Contains public sector information licensed under the [Open Government Licence v3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence). 35 | 36 | This book contains the *lectures* component of [granolarr](https://github.com/sdesabbata/granolarr), a repository of reproducible materials to teach geographic information and data science in R. Part of the materials are derived from the lectures for the module [GY7702 Practical Programming in R](https://sdesabbata.github.io/GY7702/) of the [MSc in Geographic Information Science](https://le.ac.uk/courses/geographical-information-science-msc/2019) at the [School of Geography, Geology, and the Environment](https://le.ac.uk/gge) of the [University of Leicester](https://le.ac.uk/), by [Dr Stefano De Sabbata](https://stefanodesabbata.com/). 37 | 38 | This book was created using [R](https://www.r-project.org/), [RStudio](https://www.rstudio.com/), [RMarkdown](https://rmarkdown.rstudio.com/), [Bookdown](https://bookdown.org/), and [GitHub](https://github.com/sdesabbata). 39 | 40 | 41 | 42 | ## Session info {-} 43 | ```{r} 44 | sessionInfo() 45 | ``` 46 | -------------------------------------------------------------------------------- /src/lectures/images/296px-Colored_neural_network.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/296px-Colored_neural_network.svg.png -------------------------------------------------------------------------------- /src/lectures/images/489px-Linear_least_squares_example2.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/489px-Linear_least_squares_example2.svg.png -------------------------------------------------------------------------------- /src/lectures/images/ANN_description.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/ANN_description.png -------------------------------------------------------------------------------- /src/lectures/images/Colored_deep_neural_network-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Colored_deep_neural_network-01.png -------------------------------------------------------------------------------- /src/lectures/images/Colored_deep_neural_network.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Colored_deep_neural_network.ai -------------------------------------------------------------------------------- /src/lectures/images/DBSCAN-Gaussian-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/DBSCAN-Gaussian-data.png -------------------------------------------------------------------------------- /src/lectures/images/DockerDiagram_Docker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/DockerDiagram_Docker.png -------------------------------------------------------------------------------- /src/lectures/images/DockerDiagram_VM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/DockerDiagram_VM.png -------------------------------------------------------------------------------- /src/lectures/images/MnistExamples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/MnistExamples.png -------------------------------------------------------------------------------- /src/lectures/images/MnistExamples_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/MnistExamples_2.png -------------------------------------------------------------------------------- /src/lectures/images/Neuron3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Neuron3.png -------------------------------------------------------------------------------- /src/lectures/images/Overfitted_Data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Overfitted_Data.png -------------------------------------------------------------------------------- /src/lectures/images/Overfitting.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Overfitting.svg.png -------------------------------------------------------------------------------- /src/lectures/images/PipeOperator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/PipeOperator.png -------------------------------------------------------------------------------- /src/lectures/images/README.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | [This work](https://github.com/sdesabbata/granolarr) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html) except where specified. 4 | 5 | ## Open Licenses 6 | 7 | ### Creative Commons 8 | 9 | - [Creative Commons Attribution-ShareAlike 3.0 Unported](https://creativecommons.org/licenses/by-sa/3.0/) 10 | - [`296px-Colored_neural_network.svg.png`](https://commons.wikimedia.org/wiki/File:Colored_neural_network.svg) by Glosser.ca, via [Wikimedia Commons](https://commons.wikimedia.org) 11 | - [`489px-Linear_least_squares_example2.svg.png`](https://commons.wikimedia.org/wiki/File:Linear_least_squares_example2.svg) by Krishnavedala,via [Wikimedia Commons](https://commons.wikimedia.org) 12 | - `ANN_description.png` includes images by Egm4313.s12 and Glosser.ca, via [Wikimedia Commons](https://commons.wikimedia.org) 13 | - `Colored_deep_neural_network-01.png` derived from work by Glosser.ca, via [Wikimedia Commons](https://commons.wikimedia.org) 14 | - `Colored_deep_neural_network.ai` derived from work by Glosser.ca, via [Wikimedia Commons](https://commons.wikimedia.org) 15 | - [`Colored_neural_network.svg`](https://commons.wikimedia.org/wiki/File:Colored_neural_network.svg) by Glosser.ca, via [Wikimedia Commons](https://commons.wikimedia.org) 16 | - [`DBSCAN-Gaussian-data.png`](https://commons.wikimedia.org/wiki/File:DBSCAN-Gaussian-data.svg) by Chire,via [Wikimedia Commons](https://commons.wikimedia.org) 17 | - [`Neuron3.png`](https://commons.wikimedia.org/wiki/File:Neuron3.png) iby Egm4313.s12, via [Wikimedia Commons](https://commons.wikimedia.org) 18 | - [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported](https://creativecommons.org/licenses/by-nc-sa/3.0/) 19 | - `git_snapshots.png` by Scott Chacon and Ben Straub, via [Pro Git book](https://git-scm.com/book/en/v2) 20 | - `git_three_stages.png` by Scott Chacon and Ben Straub, via [Pro Git book](https://git-scm.com/book/en/v2) 21 | - [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/) 22 | - `artificial_neuron.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 23 | - `DockerDiagram_Docker.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 24 | - `DockerDiagram_VM.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 25 | - `joins.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 26 | - [`MnistExamples.png`](https://commons.wikimedia.org/wiki/File:MnistExamples.png) by Josef Steppan, via [Wikimedia Commons](https://commons.wikimedia.org) 27 | - `MnistExamples_2.png` derived from work by Josef Steppan, via [Wikimedia Commons](https://commons.wikimedia.org) 28 | - [`Overfitted_Data.png`](https://commons.wikimedia.org/wiki/File:Overfitted_Data.png) by Ghiles, via [Wikimedia Commons](https://commons.wikimedia.org) 29 | - [`Overfitting.svg.png`](https://commons.wikimedia.org/wiki/File:Overfitting.svg) by Chabacano, via [Wikimedia Commons](https://commons.wikimedia.org) 30 | - `PipeOperator.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 31 | - [`Typical_cnn.png`](https://commons.wikimedia.org/wiki/File:Typical_cnn.png) by Aphex34, via [Wikimedia Commons](https://commons.wikimedia.org) 32 | - [Creative Commons CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/deed.en) 33 | - [Reinforcement learning diagram.svg.png](https://en.wikipedia.org/wiki/File:Reinforcement_learning_diagram.svg) by Megajuice, via [Wikimedia Commons](https://commons.wikimedia.org) 34 | -------------------------------------------------------------------------------- /src/lectures/images/Reinforcement_learning_diagram.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Reinforcement_learning_diagram.svg.png -------------------------------------------------------------------------------- /src/lectures/images/Typical_cnn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/Typical_cnn.png -------------------------------------------------------------------------------- /src/lectures/images/artificial_neuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/artificial_neuron.png -------------------------------------------------------------------------------- /src/lectures/images/git_snapshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/git_snapshots.png -------------------------------------------------------------------------------- /src/lectures/images/git_three_stages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/git_three_stages.png -------------------------------------------------------------------------------- /src/lectures/images/joins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/lectures/images/joins.png -------------------------------------------------------------------------------- /src/practicals/104_P_Introduction.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 104" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/104_P_Introduction.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/114_P_RProgramming.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 114" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/114_P_RProgramming.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/204_P_SelectionManipulation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 204" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/204_P_SelectionManipulation.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/214_P_TableOperations.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 214" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/214_P_TableOperations.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/224_P_Reproducibility.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 224" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/224_P_Reproducibility.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/304_P_Exploratory.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 304" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/304_P_Exploratory.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/314_P_ComparingData.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 314" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/314_P_ComparingData.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/324_P_Regression.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 324" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/324_P_Regression.Rmd'} 10 | ``` 11 | -------------------------------------------------------------------------------- /src/practicals/404_P_SupervisedLearning.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 404" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/404_P_SupervisedLearning.Rmd'} 10 | ``` -------------------------------------------------------------------------------- /src/practicals/414_P_UnsupervisedLearning.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical 414" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | urlcolor: blue 7 | --- 8 | 9 | ```{r child = 'contents/414_P_UnsupervisedLearning.Rmd'} 10 | ``` 11 | -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-epub3/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-13-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-13-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-14-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-14-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-3-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-3-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-4-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-4-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-5-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-5-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-6-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-6-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-7-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/304_P_Exploratory_files/figure-latex/unnamed-chunk-7-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-epub3/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-10-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-10-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-3-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-3-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-8-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/314_P_ComparingData_files/figure-latex/unnamed-chunk-8-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-10-4.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-epub3/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-10-4.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-2.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-3.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-10-4.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-3-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-3-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-5-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-5-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-7-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/324_P_Regression_files/figure-latex/unnamed-chunk-7-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-epub3/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-10-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-10-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-17-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-17-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-6-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/404_P_SupervisedLearning_files/figure-latex/unnamed-chunk-6-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/figures-side-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/figures-side-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-14-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-epub3/unnamed-chunk-8-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/figures-side-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/figures-side-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-14-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-2.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-html/unnamed-chunk-8-3.png -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/figures-side-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/figures-side-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-10-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-10-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-11-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-11-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-12-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-12-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-2.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-14-3.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-16-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-16-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-17-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-17-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-19-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-19-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-6-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-6-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-1.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-2.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_bookdown_files/414_P_UnsupervisedLearning_files/figure-latex/unnamed-chunk-8-3.pdf -------------------------------------------------------------------------------- /src/practicals/contents/_main.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/contents/_main.rds -------------------------------------------------------------------------------- /src/practicals/contents/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical session materials | granolarr" 3 | author: "Stefano De Sabbata" 4 | date: "`r Sys.Date()`" 5 | description: "Geographic data science reproducible teaching resource in R, Practical session materials" 6 | url: 'https://sdesabbata.github.io/granolarr/' 7 | github-repo: "sdesabbata/granolarr" 8 | site: bookdown::bookdown_site 9 | documentclass: book 10 | biblio-style: apalike 11 | output: 12 | bookdown::gitbook: 13 | config: 14 | toc: 15 | before: | 16 |
  • Practicals | granolarr
  • 17 | after: | 18 |
  • granolarr
  • 19 | search: yes 20 | download: 21 | - ["granolarr_practical_session_materials.pdf", "PDF"] 22 | - ["granolarr_practical_session_materials.epub", "EPUB"] 23 | bookdown::pdf_book: 24 | latex_engine: xelatex 25 | --- 26 | 27 | # Preface {-} 28 | 29 | *[Stefano De Sabbata](https://stefanodesabbata.com)* 30 | 31 | [This work](https://github.com/sdesabbata/GY7702) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html). Contains public sector information licensed under the [Open Government Licence v3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence). 32 | 33 | This book contains the *practical sessions* component of [granolarr](https://github.com/sdesabbata/granolarr), a repository of reproducible materials to teach geographic information and data science in R. Part of the materials are derived from the practical sessions for the module [GY7702 Practical Programming in R](https://sdesabbata.github.io/GY7702/) of the [MSc in Geographic Information Science](https://le.ac.uk/courses/geographical-information-science-msc/2019) at the [School of Geography, Geology, and the Environment](https://le.ac.uk/gge) of the [University of Leicester](https://le.ac.uk/), by [Dr Stefano De Sabbata](https://stefanodesabbata.com/). 34 | 35 | This book was created using [R](https://www.r-project.org/), [RStudio](https://www.rstudio.com/), [RMarkdown](https://rmarkdown.rstudio.com/), [Bookdown](https://bookdown.org/), and [GitHub](https://github.com/sdesabbata). 36 | 37 | 38 | 39 | ## Session info {-} 40 | ```{r} 41 | sessionInfo() 42 | ``` 43 | -------------------------------------------------------------------------------- /src/practicals/images/ANOVA_output_annotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/ANOVA_output_annotated.png -------------------------------------------------------------------------------- /src/practicals/images/PipeOperator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/PipeOperator.png -------------------------------------------------------------------------------- /src/practicals/images/README.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | [This work](https://github.com/sdesabbata/granolarr) is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html) except where specified. 4 | 5 | ## Open Licenses 6 | 7 | ### Creative Commons 8 | 9 | - [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported](https://creativecommons.org/licenses/by-nc-sa/3.0/) 10 | - `git_three_stages.png` by Scott Chacon and Ben Straub, via [Pro Git book](https://git-scm.com/book/en/v2) 11 | - [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/) 12 | - `ANOVA_output_annotated.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 13 | - `artificial_neuron.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 14 | - `joins.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 15 | - `PipeOperator.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 16 | - `Regression_output_annotated.png` by Stefano De Sabbata ([granolarr](https://github.com/sdesabbata/granolarr)) 17 | -------------------------------------------------------------------------------- /src/practicals/images/Regression_output_annotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/Regression_output_annotated.png -------------------------------------------------------------------------------- /src/practicals/images/artificial_neuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/artificial_neuron.png -------------------------------------------------------------------------------- /src/practicals/images/git_three_stages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/git_three_stages.png -------------------------------------------------------------------------------- /src/practicals/images/joins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/practicals/images/joins.png -------------------------------------------------------------------------------- /src/practicals/materials/functions.R: -------------------------------------------------------------------------------- 1 | cube_root <- function (x) { 2 | result <- x ^ (1 / 3) 3 | result 4 | } 5 | 6 | circle_area <- function (radius) { 7 | result <- pi * (radius^2) 8 | result 9 | } -------------------------------------------------------------------------------- /src/utils/Create_2011OAC_Leicester_dataset.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Office for National Statistics 3 | # to create a small dataset containing all the 167 variables 4 | # used in the 2011 OAC (https://github.com/geogale/2011OAC) 5 | # for the Output Area in Leicester City 6 | # Author: Stefano De Sabbata 7 | # Date: 17 July 2019 8 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 | ########## 10 | 11 | # Download the file 2011 OAC Variables - 167 Initial.zip in the storage folder 12 | # http://tiny.cc/OAC-Var-167 13 | 14 | # Download the file OA11_LSOA11_MSOA11_LAD11_EW_LU.zip in the storage folder 15 | # https://borders.ukdataservice.ac.uk/lut_download_data.html?data=oa11_lsoa11_msoa11_lad11_ew_lu 16 | 17 | library(tidyverse) 18 | library(sp) 19 | library(rgdal) 20 | 21 | # Create tmp dir if necessary 22 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp"))), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp"))), FALSE) 23 | 24 | # Extract data files 25 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "2011 OAC 167 Variables"))) { 26 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/2011 OAC Variables - 167 Initial.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp")) 27 | } 28 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU"))) { 29 | dir.create(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU")) 30 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/OA11_LSOA11_MSOA11_LAD11_EW_LU.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU")) 31 | } 32 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "E06000016"))) { 33 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "e06000016.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp")) 34 | } 35 | 36 | 37 | # Load data 38 | 39 | vars_2011OAC <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables/2011_OAC_Raw_uVariables.csv")) 40 | 41 | areas_lookup <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU/OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv"), 42 | col_types = cols( 43 | OA11CD = col_character(), 44 | LSOA11CD = col_character(), 45 | LSO11ANM = col_character(), 46 | MSOA11CD = col_character(), 47 | MSOA11NM = col_character(), 48 | LAD11CD = col_character(), 49 | LAD11NM = col_character(), 50 | LAD11NMW = col_character() 51 | ) 52 | ) %>% 53 | select(-LAD11NMW) 54 | 55 | leic_2011OAC <- readOGR(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000016/E06000016_Leicester.shp")) 56 | leic_2011OAC_data <- leic_2011OAC@data 57 | 58 | # Join data and write 59 | leic_vars_2011OAC <- areas_lookup %>% 60 | right_join(leic_2011OAC_data, by = c("OA11CD" = "oa_code")) %>% 61 | left_join(vars_2011OAC, by = c("OA11CD" = "OA")) %>% 62 | write_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "2011_OAC_Raw_uVariables_Leicester.csv")) 63 | 64 | # Copy variable names look-up file 65 | file.copy( 66 | paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables/2011_OAC_Raw_uVariables_Lookup.csv"), 67 | paste0(Sys.getenv("GRANOLARR_HOME"), "/data") 68 | ) 69 | 70 | # Clean 71 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables"), recursive = TRUE) 72 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU"), recursive = TRUE) 73 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000016"), recursive = TRUE) 74 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 75 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 76 | } -------------------------------------------------------------------------------- /src/utils/Create_2011OAC_Leicester_dataset_supgrp.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Office for National Statistics 3 | # to create a small dataset containing all the 167 variables 4 | # used in the 2011 OAC (https://github.com/geogale/2011OAC) 5 | # for the Output Area in Leicester City 6 | # Author: Stefano De Sabbata 7 | # Date: 17 July 2019 8 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 | ########## 10 | 11 | # First create 2011_OAC_Raw_uVariables_Leicester.csv 12 | # using the script Create_2011OAC_Leicester_dataset.R 13 | 14 | readr::read_csv( 15 | paste0( 16 | Sys.getenv("GRANOLARR_HOME"), 17 | "/data/", 18 | "2011_OAC_Raw_uVariables_Leicester.csv" 19 | ) 20 | ) %>% 21 | dplyr::select(OA11CD,LSOA11CD, supgrpcode,supgrpname,Total_Population) %>% 22 | readr::write_csv( 23 | paste0( 24 | Sys.getenv("GRANOLARR_HOME"), 25 | "/data/", 26 | "2011_OAC_supgrp_Leicester.csv" 27 | ) 28 | ) -------------------------------------------------------------------------------- /src/utils/Create_2011OAC_Leicestershire_dataset.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Office for National Statistics 3 | # to create a small dataset containing all the 167 variables 4 | # used in the 2011 OAC (https://github.com/geogale/2011OAC) 5 | # for the Output Area in Rutland City 6 | # Author: Stefano De Sabbata 7 | # Date: 16 December 2020 8 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 | ########## 10 | 11 | # Download the file 2011 OAC Variables - 167 Initial.zip in the storage folder 12 | # http://tiny.cc/OAC-Var-167 13 | 14 | # Download the file OA11_LSOA11_MSOA11_LAD11_EW_LU.zip in the storage folder 15 | # https://borders.ukdataservice.ac.uk/lut_download_data.html?data=oa11_lsoa11_msoa11_lad11_ew_lu 16 | 17 | rm(list = ls()) 18 | 19 | library(tidyverse) 20 | library(sp) 21 | library(rgdal) 22 | 23 | # Create tmp dir if necessary 24 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), FALSE) 25 | 26 | # Extract data files 27 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "2011 OAC 167 Variables"))) { 28 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/2011 OAC Variables - 167 Initial.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp")) 29 | } 30 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU"))) { 31 | dir.create(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU")) 32 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/OA11_LSOA11_MSOA11_LAD11_EW_LU.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU")) 33 | } 34 | 35 | 36 | # Load data 37 | 38 | vars_2011OAC <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables/2011_OAC_Raw_uVariables.csv")) 39 | 40 | areas_lookup <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU/OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv"), 41 | col_types = cols( 42 | OA11CD = col_character(), 43 | LSOA11CD = col_character(), 44 | LSO11ANM = col_character(), 45 | MSOA11CD = col_character(), 46 | MSOA11NM = col_character(), 47 | LAD11CD = col_character(), 48 | LAD11NM = col_character(), 49 | LAD11NMW = col_character() 50 | ) 51 | ) %>% 52 | select(-LAD11NMW) 53 | 54 | # Join data and write 55 | areas_lookup %>% 56 | left_join(vars_2011OAC, by = c("OA11CD" = "OA")) %>% 57 | dplyr::filter(LAD11NM %in% c("Blaby", "Charnwood", "Harborough", "Hinckley and Bosworth", "Melton", "North West Leicestershire", "Oadby and Wigston")) %>% 58 | write_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "2011_OAC_Raw_uVariables_Leicestershire.csv")) 59 | 60 | # Clean 61 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables"), recursive = TRUE) 62 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU"), recursive = TRUE) 63 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000017"), recursive = TRUE) 64 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 65 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 66 | } 67 | 68 | rm(list = ls()) -------------------------------------------------------------------------------- /src/utils/Create_2011OAC_Rutland_dataset.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Office for National Statistics 3 | # to create a small dataset containing all the 167 variables 4 | # used in the 2011 OAC (https://github.com/geogale/2011OAC) 5 | # for the Output Area in Rutland City 6 | # Author: Stefano De Sabbata 7 | # Date: 16 December 2020 8 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 | ########## 10 | 11 | # Download the file 2011 OAC Variables - 167 Initial.zip in the storage folder 12 | # http://tiny.cc/OAC-Var-167 13 | 14 | # Download the file OA11_LSOA11_MSOA11_LAD11_EW_LU.zip in the storage folder 15 | # https://borders.ukdataservice.ac.uk/lut_download_data.html?data=oa11_lsoa11_msoa11_lad11_ew_lu 16 | 17 | rm(list = ls()) 18 | 19 | library(tidyverse) 20 | library(sp) 21 | library(rgdal) 22 | 23 | # Create tmp dir if necessary 24 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), FALSE) 25 | 26 | # Extract data files 27 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "2011 OAC 167 Variables"))) { 28 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/2011 OAC Variables - 167 Initial.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp")) 29 | } 30 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU"))) { 31 | dir.create(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU")) 32 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/OA11_LSOA11_MSOA11_LAD11_EW_LU.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU")) 33 | } 34 | 35 | 36 | # Load data 37 | 38 | vars_2011OAC <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables/2011_OAC_Raw_uVariables.csv")) 39 | 40 | areas_lookup <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU/OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv"), 41 | col_types = cols( 42 | OA11CD = col_character(), 43 | LSOA11CD = col_character(), 44 | LSO11ANM = col_character(), 45 | MSOA11CD = col_character(), 46 | MSOA11NM = col_character(), 47 | LAD11CD = col_character(), 48 | LAD11NM = col_character(), 49 | LAD11NMW = col_character() 50 | ) 51 | ) %>% 52 | select(-LAD11NMW) 53 | 54 | # Join data and write 55 | areas_lookup %>% 56 | left_join(vars_2011OAC, by = c("OA11CD" = "OA")) %>% 57 | dplyr::filter(LAD11NM == "Rutland") %>% 58 | write_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "2011_OAC_Raw_uVariables_Rutland.csv")) 59 | 60 | # Clean 61 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables"), recursive = TRUE) 62 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU"), recursive = TRUE) 63 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000017"), recursive = TRUE) 64 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 65 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 66 | } 67 | 68 | rm(list = ls()) -------------------------------------------------------------------------------- /src/utils/Create_2011OAC_SouthLeicestershire_dataset.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Office for National Statistics 3 | # to create a small dataset containing all the 167 variables 4 | # used in the 2011 OAC (https://github.com/geogale/2011OAC) 5 | # for the Output Area in Rutland City 6 | # Author: Stefano De Sabbata 7 | # Date: 16 December 2020 8 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 | ########## 10 | 11 | # Download the file 2011 OAC Variables - 167 Initial.zip in the storage folder 12 | # http://tiny.cc/OAC-Var-167 13 | 14 | # Download the file OA11_LSOA11_MSOA11_LAD11_EW_LU.zip in the storage folder 15 | # https://borders.ukdataservice.ac.uk/lut_download_data.html?data=oa11_lsoa11_msoa11_lad11_ew_lu 16 | 17 | rm(list = ls()) 18 | 19 | library(tidyverse) 20 | library(sp) 21 | library(rgdal) 22 | 23 | # Create tmp dir if necessary 24 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), FALSE) 25 | 26 | # Extract data files 27 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "2011 OAC 167 Variables"))) { 28 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/2011 OAC Variables - 167 Initial.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp")) 29 | } 30 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU"))) { 31 | dir.create(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU")) 32 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/storage/OA11_LSOA11_MSOA11_LAD11_EW_LU.zip"), exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU")) 33 | } 34 | 35 | 36 | # Load data 37 | 38 | vars_2011OAC <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables/2011_OAC_Raw_uVariables.csv")) 39 | 40 | areas_lookup <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU/OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv"), 41 | col_types = cols( 42 | OA11CD = col_character(), 43 | LSOA11CD = col_character(), 44 | LSO11ANM = col_character(), 45 | MSOA11CD = col_character(), 46 | MSOA11NM = col_character(), 47 | LAD11CD = col_character(), 48 | LAD11NM = col_character(), 49 | LAD11NMW = col_character() 50 | ) 51 | ) %>% 52 | select(-LAD11NMW) 53 | 54 | # Join data and write 55 | areas_lookup %>% 56 | left_join(vars_2011OAC, by = c("OA11CD" = "OA")) %>% 57 | dplyr::filter(LAD11NM %in% c("Blaby", "Harborough", "Oadby and Wigston")) %>% 58 | write_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "2011_OAC_Raw_uVariables_SouthLeicestershire.csv")) 59 | 60 | # Clean 61 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/2011 OAC 167 Variables"), recursive = TRUE) 62 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU"), recursive = TRUE) 63 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000017"), recursive = TRUE) 64 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 65 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 66 | } 67 | 68 | rm(list = ls()) -------------------------------------------------------------------------------- /src/utils/Create_IMD2015_Leicester_dataset.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code uses data from the Ministry of Housing, Communities & Local Government 3 | # to create a small dataset containing the Indexes of Multiple deprivation 2015 4 | # for the Output Area in Leicester City 5 | # Author: Stefano De Sabbata 6 | # Date: 17 July 2019 7 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 8 | ########## 9 | 10 | # Download the file containing the Indexes of Multiple deprivation 2015 in the Storage folder 11 | # http://opendatacommunities.org/def/concept/folders/themes/societal-wellbeing 12 | # Column name 'Indices of Deprivation' edited to 'IndicesOfDeprivation' 13 | 14 | library(tidyverse) 15 | library(sp) 16 | library(rgdal) 17 | 18 | # Create tmp dir if necessary 19 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), FALSE) 20 | 21 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU"))) { 22 | dir.create(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "OA11_LSOA11_MSOA11_LAD11_EW_LU")) 23 | unzip( 24 | paste0(Sys.getenv("GRANOLARR_HOME"), "/Storage/OA11_LSOA11_MSOA11_LAD11_EW_LU.zip"), 25 | exdir = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU") 26 | ) 27 | } 28 | 29 | 30 | # Load data 31 | 32 | imd2015_england <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/Storage/8babf8b5-cc36-44a5-acd0-0e7dac5bc84d.csv")) %>% 33 | mutate(IndicesOfDeprivation = str_sub(IndicesOfDeprivation, start = 4)) 34 | 35 | leicester_lsoa <- read_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU/OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv"), 36 | col_types = cols( 37 | OA11CD = col_character(), 38 | LSOA11CD = col_character(), 39 | LSO11ANM = col_character(), 40 | MSOA11CD = col_character(), 41 | MSOA11NM = col_character(), 42 | LAD11CD = col_character(), 43 | LAD11NM = col_character(), 44 | LAD11NMW = col_character() 45 | ) 46 | ) %>% 47 | filter(LAD11NM == "Leicester") %>% 48 | select(LSOA11CD) %>% 49 | unique() 50 | 51 | # Join data and write 52 | imd2015_leicester <- imd2015_england %>% 53 | filter(FeatureCode %in% leicester_lsoa$LSOA11CD) %>% 54 | write_csv(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "IndexesMultipleDeprivation2015_Leicester.csv")) 55 | 56 | # Clean 57 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/OA11_LSOA11_MSOA11_LAD11_EW_LU"), recursive = TRUE) 58 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 59 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 60 | } -------------------------------------------------------------------------------- /src/utils/IOSlides/README.md: -------------------------------------------------------------------------------- 1 | # IOSlides 2 | 3 | The images in this folder representing the logo and crest of the [University of Leicester](https://le.ac.uk/) are protected by copyright. -------------------------------------------------------------------------------- /src/utils/IOSlides/UoL_Template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | $if(date-meta)$ 14 | 15 | $endif$ 16 | 17 | 18 | 19 | 20 | 21 | 22 | 56 | 57 | $for(header-includes)$ 58 | $header-includes$ 59 | $endfor$ 60 | 61 | 234 | 235 | $for(css)$ 236 | 237 | $endfor$ 238 | 239 | 240 | 241 | 242 | 243 | $if(widescreen)$ 244 | 245 | $else$ 246 | 247 | $endif$ 248 | 249 | $if(include-before)$ 250 | $for(include-before)$ 251 | $include-before$ 252 | $endfor$ 253 | $else$ 254 | 255 | $if(logo)$ 256 | 257 | $endif$ 258 | 259 |
    260 |

    261 |

    262 |

    263 | $author.name$
    264 | $author.company$ 265 | $author.email$ 266 |

    267 | $if(date)$ 268 |

    $date$

    269 | $endif$ 270 |
    271 |
    272 | $endif$ 273 | 274 | RENDERED_SLIDES 275 | 276 | $for(include-after)$ 277 | $include-after$ 278 | $endfor$ 279 | 280 | 281 | 282 |
    283 | 284 | $if(mathjax-url)$ 285 | 286 | 294 | $endif$ 295 | 296 | 297 | 309 | 310 | 311 | 312 | -------------------------------------------------------------------------------- /src/utils/IOSlides/UoL_Template_UniColours.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | $if(date-meta)$ 14 | 15 | $endif$ 16 | 17 | 18 | 19 | 20 | 21 | 22 | 56 | 57 | $for(header-includes)$ 58 | $header-includes$ 59 | $endfor$ 60 | 61 | 163 | 164 | $for(css)$ 165 | 166 | $endfor$ 167 | 168 | 169 | 170 | 171 | 172 | $if(widescreen)$ 173 | 174 | $else$ 175 | 176 | $endif$ 177 | 178 | $if(include-before)$ 179 | $for(include-before)$ 180 | $include-before$ 181 | $endfor$ 182 | $else$ 183 | 184 | $if(logo)$ 185 | 186 | $endif$ 187 | 188 |
    189 |

    190 |

    191 |

    192 | $author.name$
    193 | $author.company$ 194 | $author.email$ 195 |

    196 | $if(date)$ 197 |

    $date$

    198 | $endif$ 199 |
    200 |
    201 | $endif$ 202 | 203 | RENDERED_SLIDES 204 | 205 | $for(include-after)$ 206 | $include-after$ 207 | $endfor$ 208 | 209 | 210 | 211 |
    212 | 213 | $if(mathjax-url)$ 214 | 215 | 223 | $endif$ 224 | 225 | 226 | 238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /src/utils/IOSlides/uol_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/utils/IOSlides/uol_logo.png -------------------------------------------------------------------------------- /src/utils/IOSlides/uol_logo_colour.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdesabbata/granolarr/358d7b9b2d89d6d42c0faee20a3afefdb3343688/src/utils/IOSlides/uol_logo_colour.png -------------------------------------------------------------------------------- /src/utils/Leicester_Pride_2019.R: -------------------------------------------------------------------------------- 1 | ########## 2 | # This code creates a map of the Census Output Areas 3 | # in Leicester with the Pride Flag colours 4 | # Author: Stefano De Sabbata 5 | # Date: 30 August 2019 6 | # Licensed under the GNU General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 7 | ########## 8 | 9 | library(tidyverse) 10 | library(sp) 11 | library(rgdal) 12 | library(rgeos) 13 | #library(tmap) 14 | library(ggmap) 15 | library(ggthemes) 16 | library(ggplot2) 17 | 18 | rm(list=ls()) 19 | 20 | # Create tmp dir if necessary 21 | ifelse(!dir.exists(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), dir.create(file.path(Sys.getenv("GRANOLARR_HOME"), "/tmp")), FALSE) 22 | 23 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "E06000016"))) { 24 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "e06000016.zip"), exdir = "tmp") 25 | } 26 | if (!dir.exists(file.path(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), "England_ct_2011_Leicestershire"))) { 27 | unzip(paste0(Sys.getenv("GRANOLARR_HOME"), "/data/", "England_ct_2011_Leicestershire.zip"), exdir = "tmp") 28 | } 29 | 30 | 31 | # Load data 32 | leic_2011OAC <- readOGR(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000016/E06000016_Leicester.shp")) 33 | leic_2011OAC <- spTransform(leic_2011OAC, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")) 34 | england_ct_2011 <- readOGR(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/England_ct_2011_Leicestershire/england_ct_2011_Leicestershire.shp")) 35 | england_ct_2011 <- spTransform(england_ct_2011, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")) 36 | 37 | # Calculate centroids 38 | leic_2011OAC_coords <- coordinates(leic_2011OAC) 39 | 40 | leic_2011OAC_centroids_coords <- data.frame( 41 | oa_code = leic_2011OAC$oa_code, 42 | x = leic_2011OAC_coords[, 1], 43 | y = leic_2011OAC_coords[, 2] 44 | ) 45 | 46 | # Calculate overall span 47 | leic_2011OAC_y_min <- min(leic_2011OAC_centroids_coords$y) 48 | leic_2011OAC_y_max <- max(leic_2011OAC_centroids_coords$y) 49 | leic_2011OAC_step <- (leic_2011OAC_y_max - leic_2011OAC_y_min) / 6 50 | 51 | # Flag colours 52 | lgbt_flag_colours_list <- c("#86007d", "#0000f9", "#008018", "#ffff41", "#ffa52c", "#ff0018") 53 | lgbt_flag_colours <- data.frame( 54 | lgbt_flag_colour_val = c(1, 2, 3, 4, 5, 6), 55 | lgbt_flag_colour = lgbt_flag_colours_list 56 | ) 57 | 58 | # Assign values 59 | leic_2011OAC_centroids_coords$lgbt_flag_colour_val <- floor((leic_2011OAC_centroids_coords$y - leic_2011OAC_y_min) / leic_2011OAC_step) + 1 60 | leic_2011OAC_centroids_coords$lgbt_flag_colour_val <- ifelse(leic_2011OAC_centroids_coords$lgbt_flag_colour_val>6, 6, leic_2011OAC_centroids_coords$lgbt_flag_colour_val) 61 | 62 | # Merge with flag colours 63 | leic_2011OAC_centroids_coords <- merge(leic_2011OAC_centroids_coords, lgbt_flag_colours, by = "lgbt_flag_colour_val") 64 | 65 | # Merge back with OAs 66 | leic_2011OAC <- merge(leic_2011OAC, leic_2011OAC_centroids_coords, by = "oa_code") 67 | leic_2011OAC$lgbt_flag_colour <- as.character(leic_2011OAC$lgbt_flag_colour) 68 | leic_2011OAC$lgbt_flag_colour_val <- as.factor(leic_2011OAC$lgbt_flag_colour_val) 69 | 70 | leic_2011OAC_points = fortify(leic_2011OAC, region = "oa_code") 71 | leic_2011OAC_df = merge(leic_2011OAC_points, leic_2011OAC@data, by.x = "id", by.y = "oa_code") 72 | 73 | # Map 74 | #tm_shape(leic_2011OAC) + 75 | # tm_fill(col = "lgbt_flag_colour") + 76 | # tm_borders("gray40", alpha=.5) + 77 | # tm_layout(frame=FALSE) + 78 | #tm_shape(england_ct_2011) + 79 | # tm_borders("black") + 80 | 81 | # Leicester 82 | ggmap( 83 | get_stamenmap( 84 | c(left = -1.225, bottom = 52.575, right = -1.0, top = 52.7), 85 | zoom = 13, 86 | maptype = "toner-lite" 87 | ) 88 | )+ 89 | geom_polygon( 90 | data = leic_2011OAC_df, 91 | aes( 92 | x = long, 93 | y = lat, 94 | group = group, 95 | fill = lgbt_flag_colour_val, 96 | alpha = 0.5 97 | ) 98 | ) + 99 | geom_path( 100 | data = leic_2011OAC_df, 101 | aes( 102 | x = long, 103 | y = lat, 104 | group = group 105 | ), 106 | colour = "#969696", 107 | alpha = 0.5, 108 | size = 0.25 109 | ) + 110 | geom_path( 111 | data = england_ct_2011, 112 | aes( 113 | x = long, 114 | y = lat, 115 | group = group 116 | ), 117 | colour = "#000000", 118 | alpha = 0.5 119 | ) + 120 | scale_fill_manual(values = lgbt_flag_colours_list) + 121 | guides( 122 | colour = FALSE, 123 | fill = FALSE, 124 | alpha = FALSE 125 | ) + 126 | xlab("") + ylab("") + 127 | theme( 128 | #legend.position = "bottom", 129 | axis.text.x = element_blank(), 130 | axis.text.y = element_blank(), 131 | axis.ticks = element_blank() 132 | ) 133 | 134 | # Clean 135 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/England_ct_2011_Leicestershire"), recursive = TRUE) 136 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp/E06000016"), recursive = TRUE) 137 | if(length(list.files(path = paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), include.dirs = TRUE)) == 0){ 138 | unlink(paste0(Sys.getenv("GRANOLARR_HOME"), "/tmp"), recursive = TRUE) 139 | } 140 | rm(list=ls()) -------------------------------------------------------------------------------- /src/utils/RMarkdown/rmarkdown_classes.css: -------------------------------------------------------------------------------- 1 | .cols {display: flex; } 2 | 3 | .col img { 4 | width: 90%; 5 | } -------------------------------------------------------------------------------- /src/utils/RMarkdown/rmarkdown_classes.tex: -------------------------------------------------------------------------------- 1 | \newenvironment{cols}[1][]{}{} 2 | 3 | \newenvironment{col}[1]{\begin{minipage}{#1}\ignorespaces}{% 4 | \end{minipage} 5 | \ifhmode\unskip\fi 6 | \aftergroup\useignorespacesandallpars} 7 | 8 | \def\useignorespacesandallpars#1\ignorespaces\fi{% 9 | #1\fi\ignorespacesandallpars} 10 | 11 | \makeatletter 12 | \def\ignorespacesandallpars{% 13 | \@ifnextchar\par 14 | {\expandafter\ignorespacesandallpars\@gobble}% 15 | {}% 16 | } 17 | \makeatother 18 | 19 | \newenvironment{small_r_all}{\footnotesize}{} 20 | \newenvironment{small_r_output}{\footnotesize}{} 21 | \newenvironment{verysmall_r_output}{\tiny}{} 22 | \newenvironment{veryverysmall_r_all}{\tiny}{} --------------------------------------------------------------------------------