class: center, middle, inverse, title-slide .title[ # Geospatial Analysis with R ] .subtitle[ ## Class 3 ] --- ```r library(raster) library(ggplot2) library(rasterVis) library(gstat) # dummy grids, with spatial autocorrelation, normalized xy <- expand.grid(1:50, 1:50) names(xy) <- c('x', 'y') set.seed(2) # 2 gdummy <- gstat(formula = z ~ 1, locations = ~x + y, dummy = TRUE, beta = 1, model = vgm(psill = 0.35, range = 30, model = 'Sph'), nmax = 20) yy <- predict(gdummy, newdata = xy, nsim = 4) gridded(yy) <- ~x + y yy <- raster(yy) yy <- focal(yy, w = matrix(1, 3, 3), mean, na.rm = TRUE, pad = TRUE) png("inst/slides/figures/random-raster.png", height = 5, width = 5, res = 300, units = "in", bg = "transparent") lattice.options(layout.heights = list(bottom.padding = list(x = 0), top.padding = list(x = 0)), layout.widths = list(left.padding = list(x = 0), right.padding = list(x = 0))) levelplot(yy, scales = list(draw = FALSE), axes = FALSE, colorkey = list(axis.line = list(col = "white"), axis.text = list(col = "white"))) dev.off() ``` --- # Today's Topics - Trouble-shooting - `R` packages - `git` / GitHub - Overview of assignment - Keeping up to date with class materials - Tips and tricks for productivity - Seeking help as a skillset --- # R packages - File structure - Where packages live - library versus package - Exported functions, loading packages --- ## Types of packages <div class="figure" style="text-align: center"> <img src="http://r-pkgs.had.co.nz/diagrams/package-files.png" alt="http://r-pkgs.had.co.nz/package.html" width="55%" /> <p class="caption">http://r-pkgs.had.co.nz/package.html</p> </div> --- ## Installing packages <div class="figure" style="text-align: center"> <img src="https://r-pkgs.org/diagrams/install-load.png" alt="http://r-pkgs.had.co.nz/package.html" width="90%" /> <p class="caption">http://r-pkgs.had.co.nz/package.html</p> </div> --- # `git` / GitHub - Commits, pushes, pulls - Branching - Merging --- <div class="figure" style="text-align: center"> <img src="https://kevintshoemaker.github.io/StatsChats/GIT1.png" alt="kevintshoemaker.github.io/StatsChats/GIT_tutorial" width="70%" /> <p class="caption">kevintshoemaker.github.io/StatsChats/GIT_tutorial</p> </div> --- <div class="figure" style="text-align: center"> <img src="https://kevintshoemaker.github.io/StatsChats/GIT2.png" alt="kevintshoemaker.github.io/StatsChats/GIT_tutorial" width="70%" /> <p class="caption">kevintshoemaker.github.io/StatsChats/GIT_tutorial</p> </div> --- <div class="figure" style="text-align: center"> <img src="https://i.stack.imgur.com/yof9f.png" alt="stackoverflow.com/questions/7212740/why-git-is-called-a-distributed-source-control-system" width="70%" /> <p class="caption">stackoverflow.com/questions/7212740/why-git-is-called-a-distributed-source-control-system</p> </div> --- ## Our Branching Model <img src="figures/class3_1.png" width="70%" style="display: block; margin: auto;" /> --- ## Keeping current - Using `git` and GitHub - Following [4.3.4.](https://agroimpacts.github.io/geospaar/unit1-module1.html#cloning-the-remote-repo) of Unit 1 - Module 1 --- # [Assignment 1]("https://agroimpacts.github.io/geospaar/unit1-module1.html#unit-assignment") - Due Monday (29th) --- # Tips and Tricks - Tab completion and shortcuts - Reusing code - Code syntax - [Posting guide](https://www.r-project.org/posting-guide.html) --- ## Knowing how to get help as a skillset - Slack posting guide - Getting help via the search engine - (Eventually) posting to listserves --- ## Search Engine Science - Sometimes you just need the error message <img src="figures/class3_4.jpeg" width="90%" style="display: block; margin: auto;" /> --- ## Search Engine Science - Sometimes you need to search ``` fatal: unable to access 'https://github.com/agroimpacts/xyz346.git/': error setting certificate verify locations: CAfile: C:/Users/xyz/Desktop/ADP/RStudio/xyz346/Git/mingw64/ssl/ certs/ca-bundle.crt CApath: none ``` - How you search matters --- <img src="figures/class3_5.png" width="90%" style="display: block; margin: auto;" /> --- ## Listserves <img src="figures/class3_3.png" width="90%" style="display: block; margin: auto;" />