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
  • git / GitHub
  • R packages

git / GitHub

  • What is version control and what is the advantage of using it?
  • What is git and what is GitHub?
  • What is a commits? A push? A pull?
  • Which is a branch, how do we create them, and how will we use them in this class?
  • What is a merge?

R packages

  • What is an R package and why do we use them?
  • What is the file/folder structure of an R package and what are the key package files?
  • What is an R function, and what is the advantage of using them? What is a package function, and how and why do we export package functions?
  • How do we load packages?
  • Where does an installed package live?
  • What is the difference between a library and a package?

git/GitHub extras

kevintshoemaker.github.io/StatsChats/GIT_tutorial

kevintshoemaker.github.io/StatsChats/GIT_tutorial

Our Branching Model

Keeping the repo current

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

Types of R packages

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

Installing packages

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

Assignment 1

  • Due Friday midnight (9/4)

Tips and Tricks

  • Tab completion and shortcuts
  • Reusing code
  • Code syntax