-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.R
More file actions
32 lines (27 loc) · 863 Bytes
/
Copy pathmain.R
File metadata and controls
32 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Entry point — run this file to execute the full pipeline
rm(list = ls())
library(tidyverse)
library(readxl)
library(lubridate)
library(purrr)
# Assign each month to an ONI-style 3-month season label
month_to_season <- function(month) {
c("DJF", "JFM", "FMA", "MAM", "AMJ", "MJJ",
"JJA", "JAS", "ASO", "SON", "OND", "NDJ")[month]
}
# Add Season and Season_Year columns to a df that has Month and Year columns.
# Dec/Nov seasons are attributed to the following calendar year.
add_season_year <- function(df) {
df %>% mutate(
Season = month_to_season(Month),
Season_Year = case_when(
Season == "DJF" & Month == 12 ~ Year + 1,
Season == "NDJ" & Month %in% c(11, 12) ~ Year + 1,
TRUE ~ Year
)
)
}
source("ONI_scraper.R")
source("SHELDUS.R")
source("emPOWER.R")
source("Joining.R")