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

http://r-pkgs.had.co.nz/package.html

Installing packages

http://r-pkgs.had.co.nz/package.html

git / GitHub

  • Commits, pushes, pulls
  • Branching
  • Merging

kevintshoemaker.github.io/StatsChats/GIT_tutorial

kevintshoemaker.github.io/StatsChats/GIT_tutorial

Our Branching Model

Keeping current

  • Using git and GitHub
  • Following 4.3.4. of Unit 1 - Module 1

Assignment 1

  • Due Monday (29th)

Tips and Tricks

  • Tab completion and shortcuts
  • Reusing code
  • Code syntax
  • Posting guide

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

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

Listserves