Created
February 21, 2022 14:42
-
-
Save MJacobs1985/ea28ccac976c036815bc981b69d54e57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls()) | |
library(readxl) | |
library(caret) | |
library(dplyr) | |
library(readr) | |
library(DataExplorer) | |
library(skimr) | |
library(forecast) | |
library(lubridate) | |
library(xts) | |
library(tsbox) | |
library(TSstudio) | |
library(timetk) | |
library(tseries) | |
library(MLmetrics) | |
library(prophet) | |
library(xgboost) | |
library(tidymodels) | |
library(modeltime) | |
library(tidyverse) | |
library(hrbrthemes) | |
library(mgcv) | |
library(modelr) | |
library(knitr) | |
library(vars) | |
library(timelineR) | |
library(doParallel) | |
library(parallel) | |
library(data.table) | |
library(lme4) | |
library(sjPlot) | |
library(VCA) | |
library(MLtoolkit) | |
#### IMPORT DATA #### | |
arcraw <- read_excel("Fiskedatabase fra generasjon 05.xlsx", | |
sheet = "Marc2", col_types = c("text", | |
"text", "text", "date", "text", "text", | |
"text", "text", "numeric", "text", | |
"text", "numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "numeric", | |
"numeric", "numeric", "text", "numeric", | |
"text", "text", "text")) | |
dim(arcraw) | |
arc<-arcraw | |
##### DATA WRANGLING #### | |
### Make all column names lowercase | |
names(arc)<-tolower(names(arc)) | |
names(arcraw)<-tolower(names(arcraw)) | |
### Fill in slaughter month, quarter, and year | |
arc$slaughtermonth<-format(arc$sampledate,'%m') | |
arc$slaughteryear<-format(arc$sampledate,'%Y') | |
arc$slaughterq<-quarters(arc$sampledate) | |
dim(arc) | |
table(arc$slaughteryear) | |
plot(table(arc$slaughteryear, arc$slaughtermonth)) | |
heatmap(table(arc$slaughteryear, arc$slaughtermonth)) | |
table(is.na(arc$slaughtermonth)) | |
table(is.na(arc$slaughteryear)) | |
table(is.na(arc$slaughterq)) | |
table(is.na(arc$sampledate)) | |
### Remove NA | |
arc<-arc[!(is.na(arc$rochefant) | arc$rochefant==""), ] | |
arc$strain<-car::recode(arc$strain, | |
"c('(tom)', 'Bindalssmolt','Bolaks','Mowi','Rauma','Stofnfiskur')='REST'") | |
dim(arc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment