-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathController.R
More file actions
61 lines (45 loc) · 1.22 KB
/
Controller.R
File metadata and controls
61 lines (45 loc) · 1.22 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# refreshenvironment
# Set working directory ---------------------------------------------------
setwd("/Users/cassandrabayer/Desktop/R Scripts/Flaredown-Analysis")
# Load Packages -----------------------------------------------------------
# load basic packages
library(data.table)
library(tidyr)
library(tidyverse)
# visualization packages
library(ggplot2)
library(plotly)
# basic stats and prediction
library(stats)
library(forecast)
# Model Selection
library(MASS)
library(glmnet)
library(car)
#Dates
library(zoo)
library(lubridate)
# Load any custom functions -----------------------------------------------
rowShift <- function(x, shiftLen = 1L) {
r <- (1L + shiftLen):(length(x) + shiftLen)
r[r<1] <- NA
return(x[r])
}
shift <- function(x, offset = 1, pad = NA) {
r <- (1 + offset):(length(x) + offset)
r[r<1] <- NA
ans <- x[r]
ans[is.na(ans)] <- pad
return(ans)
}
maxMissing <- function(x){
if(all(is.na(x))){
return(NA_real_)
} else{
return(max(x, na.rm = T))
}
}
# Load data --------------------------------------------------------------
# Inital loading and basic cleaning
fd <- data.table(read.csv("fd-export 3.csv", stringsAsFactors = F))
fd[, trackable_name := tolower(trackable_name)]