Skip to content

Instantly share code, notes, and snippets.

View slarge's full-sized avatar

Scott Large slarge

  • NOAA-Fisheries
  • Woods Hole, MA
View GitHub Profile
## Download OISST for NEUS
## From: https://cran.r-project.org/web/packages/heatwaveR/vignettes/OISST_preparation.html
# The packages we will need
# install.packages("dplyr")
# install.packages("lubridate")
# install.packages("ggplot2")
@slarge
slarge / condition_plots.R
Created January 22, 2020 21:02
condition_plots.R
library(ggplot2)
library(dplyr)
library(patchwork)
library(forcats)
annualCondition <- read.csv("https://raw.githubusercontent.com/Laurels1/Condition/master/data/AnnualRelCond2018_GB.csv",
stringsAsFactors = FALSE)
@slarge
slarge / fedregs_demo.R
Created February 5, 2019 15:37
Quick demo of fedregs package to explore northeastern US fisheries regulatoins
install.packages("fedregs")
library(fedregs)
library(dplyr)
library(ggplot2)
library(quanteda)
library(magick)
## For more info, check out the fedregs github repository:
## https://github.com/slarge/fedregs
@slarge
slarge / shaded_neus.R
Created May 29, 2018 17:03
Creates a shaded relief of NEUS
# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
# library(dplyr)
library(RCurl)
# library(rnaturalearth)
library(sf)
# library(purrr)
library(data.table)
# library(reshape2)
# library(formula.tools)
## from https://eliocamp.github.io/codigo-r/2018/02/how-to-make-shaded-relief-in-r/
geom_relief <- function(mapping = NULL, data = NULL,
stat = "identity", position = "identity",
...,
raster = TRUE,
interpolate = TRUE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
@slarge
slarge / advice_year.R
Last active November 22, 2017 13:49
Function to get stocks for an advice year
## Print list of stocks for a year
#advice_year(2018)
advice_year <- function(year = 2018, path = "~/") {
list_of_packages <- c("dplyr", "glue", "jsonlite", "flextable", "officer")
new_packages <- list_of_packages[!(list_of_packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)
library(dplyr)
<?xml version="1.0" encoding="UTF-8"?>
<ns:Execute xmlns:ns="http://www.opengis.net/wps/1.0.0" service="WPS" version="1.0.0">
<ns1:Identifier xmlns:ns1="http://www.opengis.net/ows/1.1">org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.VSURF</ns1:Identifier>
<ns:DataInputs>
<ns:Input>
<ns1:Identifier xmlns:ns1="http://www.opengis.net/ows/1.1">x</ns1:Identifier>
<ns:Reference xmlns:xlin="http://www.w3.org/1999/xlink" xlin:href="#XFILE#" mimeType="text/xml" />
</ns:Input>
<ns:Input>
<ns1:Identifier xmlns:ns1="http://www.opengis.net/ows/1.1">y</ns1:Identifier>
@slarge
slarge / vsurf_bb.R
Created November 9, 2017 09:13
Variable Selection using Random Forest R function used for BB
vsurf_bb <- function(file_x,
file_y,
ntree = 100,
mtry = 2,
nfor_thres = 50,
nmin = 1,
nfor_interp = 25,
nsd = 1,
nfor_pred = 25,
parallel = "true",
@slarge
slarge / ICES_tab.R
Created November 1, 2017 10:01
explore ICES advice with tabulizer
## Exploring ICES advice ##
library(tabulizer)
library(glue)
library(dplyr)
library(stringr)
library(purrr)
library(httr)
library(jsonlite)
library(icesSAG)
library(dplyr)
ref_list <- icesSAG::getSAG(stock = NULL, year = 2017, data = "refpts")
stock_list <- jsonlite::fromJSON("http://sd.ices.dk/services/odata3/StockListDWs3",
simplifyDataFrame = TRUE)$value
all_msy <- ref_list %>%
filter(!is.na(FMSY) |