Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
## Libraries
library(tidyverse)
library(viridis)
library(lubridate)
library(gridExtra)
library(animation)
## Data
# SACTN
load("~/SACTN/data/SACTNmonthly_v4.1.Rdata")
## Subset
# Subseting function
ts.sub <- function(site){
ts <- SACTNmonthly_v4.1[SACTNmonthly_v4.1$index == site,] %>%
mutate(year = year(date),
month = month(date, label = T),
clim = mean(temp[year %in% seq(1981,2010)], na.rm = T),
anom = temp-clim) %>%
select(site, year, month, anom)
return(ts)
}
# Warming site
PN <- ts.sub("Port Nolloth/ SAWS")
# Cooling site
SP <- ts.sub("Sea Point/ SAWS")
# Flat site
KB <- ts.sub("Kent Bay/ KZNSB")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment